How to sort wordpress categories by number of posts?

Posted by

While displaying categories, by default, they are sorted by category name, alphabetically. You can change it to sort by number of post count under that category.

Categories are fetched using the below tag:


Use the below arguments to sort categories by post count:

<?php wp_list_categories(‘depth=1&hide_empty=0&orderby=count& &order=DESC&title_li=’ ); ?>

This will start with the category with the highest number of posts.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.