WordPress.org

Ready to get started?Download WordPress

Forums

Excluding child categories (6 posts)

  1. pixelgeek
    Member
    Posted 6 years ago #

    I have a blog that aggregates news and I am looking at including a new category for the company each news item is about.

    This will involve about 50 - 60 company categories and in order to keep my category listing managable I wanted to organize them in a main "Companies" category and then exclude the Companies category.

    Problem is that wp_list_categories will only exclude a parent but will still display the child categories (which seems nonsensical...)

    Is there a way to exclude the child categories of a parent or do I need to rewrite wp_list_categories?

    BTW, I have close to 40 categories that I am displaying so writing an include param is not an option.

    TIA

  2. pixelgeek
    Member
    Posted 6 years ago #

    Just to add. I did try using unfold_list_categories but it doesn't actually appear to do what I want either.

  3. MichaelH
    Member
    Posted 6 years ago #

  4. pixelgeek
    Member
    Posted 6 years ago #

    It might be a start. Thanks

    Sadly I have parent and child categories I do want to display so I'd need to do some additional coding.

  5. MichaelH
    Member
    Posted 6 years ago #

    Or resort to using the include=x,y,x parameter for template tag, wp_list_categories().

    Rewring wp_list_categories would be LAST on my list. No make that NEVER on my list ;)

  6. pixelgeek
    Member
    Posted 6 years ago #

    I'm not going to do that. Its too much of a pain in the *ss and I can't see how it would not be a resource hog of a query to run repeatedly. This sits on the front page and gets called thousands of times a day.

    I have to say that it strikes me as slightly... well dumb that child categories of a parent show up.

    Yet another oddity around the category code.

    I'll have to find some other solution.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic