WordPress.org

Ready to get started?Download WordPress

Forums

BUG: category with no content but children with content counts as empty (5 posts)

  1. palamedes
    Member
    Posted 7 years ago #

    If you have a category that in and of itself, has no posts. But has child categories that have posts and you do a wp_list_cats('hide_empty=1').. the parent category gets hidden.

    This seems like a bug to me, as the children have content.

    So forexample if you do something like this;

    wp_list_cats('sort_column=name&hide_empty=0&children='.((isset($_REQUEST['cat']))?$_REQUEST['cat']:'0'));

    Which will display categories, but only the children of the category you're in.. and you flip hide to 1, suddenly the parent category will be hidden.. this is wrong.

    Thoughts?

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Posts in a child don't count as posts in the parent unless the post is in the parent category as well.

    This is not a bug, it's how the thing is supposed to work. If you want these posts to actually be in the parent category as well, then you have to add them to the parent category explicitly.

  3. palamedes
    Member
    Posted 7 years ago #

    Okay then.. never mind.. =) It just seemed buggy is all.

    Thanks Otto..

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    The parent/child relationship of categories can be confusing in some ways. The best way to think about it is that all categories are actually separate. The only thing that the parent/child thing lets you do is to group categories together for display purposes. Posts don't actually "live" in a category, since they can belong to multiple categories.

  5. palamedes
    Member
    Posted 7 years ago #

    Ah.. valid point.. didn't think of that..

Topic Closed

This topic has been closed to new replies.

About this Topic