[resolved] Display x number of top-posted categories (3 posts)

  1. cloak42
    Posted 9 years ago #

    I would like to display in the categories section of my sidebar a list of only x amount of categories (say, a limit of 10), sorted by number of posts. So, for example, if I've got 10 posts under the "music" category, 5 in "television" and 2 in "movies", it'll display them in that order. I managed to construct a SQL query that displays the categories in order, but I have to use wordpress.wp_post2cat in order to do it:

    select category_id, count(*) as "count" from wp_post2cat group by category_id order by count desc;

    Does anybody know of a way I could construct a custom function based on list_cats() or wp_list_cats() that could accomplish this?

  2. Kafkaesqui

    Posted 9 years ago #

    This thread from a few months back explains how you can do that:


  3. cloak42
    Posted 9 years ago #

    Perfect, I don't know how I missed that in my search. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic