woocommerce products category order

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.

Read More

How can I hard-code the order or set it to order by id?

Related posts

Leave a Reply

2 comments

  1. You confused orderby with order, they’re 2 different arguments (see get_terms):

    $wcatTerms = get_terms('product_cat', array(
        'hide_empty' => 0, 
        'orderby'    => 'id',
        'order'      => 'ASC',
        'parent'     => 0
    ));
    
  2. 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.