Support » Fixing WordPress » Sort categories by total posts in hierarchy?

  • Resolved meetar

    (@pjrich)


    I have my categories in my sidebar sorted by “count”, in descending order. However, the count for categories with sub-categories doesn’t include the counts of each sub-category. Can this be changed?
    For instance:

    Cat1: 6 posts
    Cat2: 3 posts
    – Cat2A: 20 posts
    – Cat2B: 7 posts

    … It seems like Cat2 should count as having 30 posts, and be sorted above Cat1… but it ain’t. Is this possible?

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    (@esmi)

    Forum Moderator

    Each category is counted independently which is why you’re seeing the display as it is. Unfortunately, there’s no way to change this behaviour using wp_list_categories.

    Might look at the pad_counts argument with Function_Reference/get_categories.

    esmi

    (@esmi)

    Forum Moderator

    Ooo – I’d not noticed that parameter before…

    Thanks for the tip! That would likely do it, with some work.

    I think for my purposes it’ll be simpler to use the dashboard’s Bulk Actions to filter for a subcategory and make all of its members also belong to the supercategory.

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sort categories by total posts in hierarchy?’ is closed to new replies.