Avoid sub-category posts on parent category page (6 posts)

  1. kjetilgf
    Posted 7 years ago #

    This question has been up many times, but since all solutions I've found are outdated I give it a try:
    How can I avoid posts in a sub-category from being displayed on the parent-category page?
    I have a parent category called Culture and children categories called Film and Articles. On the Culture page i don't want to see the posts, just the sub categories.
    Any plugin or code that could fix this?

  2. RosieMBanks
    Posted 7 years ago #

    Read this section of the Codex: Include or Exclude Categories.

    Wherever your categories are listed in your template, you look for code like this:

    wp_list_categories(); ?>

    And change it to this:

    wp_list_categories('depth=1'); ?>
  3. RosieMBanks
    Posted 7 years ago #

    Drat. I misread the original post.

    Okay, read this: The Loop: Exclude Posts from Some Category.

    The examples are pretty good on that page, so I'll leave it at that.

  4. kjetilgf
    Posted 7 years ago #

    Thanks a lot. I'll save this one.
    I found an other solution, though. Instead of making parent/child categories i made just the children (but as normal categories). Then I made the "parent" pages as static pages with the introduction and links to the "children" from there.
    After all, the categories won't change much, so the most important was to make it possible to post to the child pages.
    http://www.dolcevita.no/wp/kultur/ is a static page and the two lower links go to category overview pages for articles and video/books
    (Never mind Cucina Italiana - its an external link)

  5. moshu
    Posted 7 years ago #

    You guys missed this nice little plugin:

  6. kjetilgf
    Posted 7 years ago #

    Thanks, Moshu.
    Found it a couple of days later and thought I'd mentioned it here.
    It seems to work fine also in WP 2.51 though its compatibility listing stops at 2.3.
    For some strange reason its not listed in the WP plugins directory.

Topic Closed

This topic has been closed to new replies.

About this Topic