-1

I have a custom order of my taxonomies in Woocommerce/Taxonomy Order.

When I display them, they get printed in alphabetical order.

How can I prevent this behavior and print them in the order I selected?

Thanks in advance!

1
  • are you using any plugin or you did it manually using coding ?
    – GKS
    Nov 23, 2016 at 11:41

1 Answer 1

0

You may consider using the get_terms() function to generate a list of the items in a custom taxonomy. I'm sure there are other good ways of doing this, but there are plenty of parameters here you can try out to get the order you need.

    $terms = get_terms( 'custom_taxonomy_here', 'orderby=count&hide_empty=0' );
        if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
        echo '<ul>';
        foreach ( $terms as $term ) {
            echo '<li>' . $term->name . '</li>';
        }
        echo '</ul>';
    }

In the example above, orderby orders the terms by their count (but there are other arguments for a different order) and hide_empty to display terms whether or not they are associated with a post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.