WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Sort categories by total posts in hierarchy? (5 posts)

  1. meetar
    Member
    Posted 4 years ago #

    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?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    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.

  3. MichaelH
    Member
    Posted 4 years ago #

    Might look at the pad_counts argument with Function_Reference/get_categories.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Ooo - I'd not noticed that parameter before...

  5. meetar
    Member
    Posted 4 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic