I have created a template and I’m using the code to show the product categories on a page:
<?php $wcatTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC', 'parent' =>0)); //, 'exclude' => '17,77'
foreach($wcatTerms as $wcatTerm) :
$wthumbnail_id = get_woocommerce_term_meta( $wcatTerm->term_id, 'thumbnail_id', true );
$wimage = wp_get_attachment_url( $wthumbnail_id );
When I change the order in the backend it won’t change.
How can I hard-code the order or set it to order by id?
You confused
orderby
withorder
, they’re 2 different arguments (seeget_terms
):Actually you do not have to hardcode anything.
1- Just go under Appearance->Widgets
2- Under sidebar you added Woocommerce Product Categories expand “Woocommerce Product Categories”
3- At Order By dropdown box choose “Category Order” instead of name.
it should work now.