categories - Woocommerce custom taxonomy order

I have a custom order of my taxonomies in WoocommerceTaxonomy Order.When I display them, they get printed in alphabetic

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!

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!

Share Improve this question asked Nov 23, 2016 at 11:35 Arno NymoArno Nymo 1 1
  • are you using any plugin or you did it manually using coding ? – GKS Commented Nov 23, 2016 at 11:41
Add a comment  | 

1 Answer 1

Reset to default 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744711717a4589381.html

相关推荐

  • categories - Woocommerce custom taxonomy order

    I have a custom order of my taxonomies in WoocommerceTaxonomy Order.When I display them, they get printed in alphabetic

    22小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信