WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to exclude 'child' category content from 'parent' category default display (9 posts)

  1. berchman
    Member
    Posted 4 years ago #

    I am trying to resolve how to exclude the child category content from displaying within the stream of parent category content.

    In other words...

    If I have 'Parent Category A', and under that, Child01, and Child02...

    When I see a page display 'Parent Category A' posts I DO NOT want to see Child01 and Child02 displayed.

    The child categories can be accessed through alternate navigation, but I cannot figure out how to exclude the child content from displaying within the parent content.

    I've looked at/installed "Advanced Category Excluder" plugin but that does not do what I want/need.

    I've also searched these forums to see if someone has a custom PHP solution and have come up empty.

    Anyone?

    Buehler??

  2. MichaelH
    Member
    Posted 4 years ago #

    This search http://www.google.com/search?q=wordpress+exclude+child+category+posts+from+parent+post+page found some stuff including http://wordpress.org/support/topic/243824?replies=4

    Essentially adding this before a loop:

    <?php
    if ( is_category() ) {
      $cat = get_query_var('cat');
      query_posts(array('category__in' => array($cat)));
    }
    ?>

    Note: by WordPress standards, ANY category that has been designated a Parent category is not meant to be checked in the category hierarchy when writing posts. Meaning, only the latest generation category should be checked. Think of it like this, only the youngest generation gets the action.

  3. DStall
    Member
    Posted 4 years ago #

    I'm using AVH Extended Categories Widgets.
    http://wordpress.org/extend/plugins/extended-categories-widget/

    In what WP file should I put your code and where?

    I know it's not per 'standards' but I have 3 parent categories to which I want to assign some posts without having their child category posts returned as well.

  4. MichaelH
    Member
    Posted 4 years ago #

  5. DStall
    Member
    Posted 4 years ago #

    How and where and what code can I put in a WP core file to change the way the AVH Extended Categories Widgets plugin pulls up posts per categories created in WP?

    All I want to do is exclude subcategories from 3 main categories.
    At Bibliography page -
    http://lifegivingspring.info/bibliography/faith
    Click on 'Ancient Faith' parent category in widget on right; then on 'Home' child category under that.
    All the same post entries are pulled up each time, but all posts are in the 'Home' child category, not in the 'Ancient Faith' parent category.

    Bibliography page has no code to create category list. That code is coming from the plugin, and there is no code in plugin php file that resembles what you or others have written.
    http://wordpress.org/extend/plugins/extended-categories-widget/

  6. DStall
    Member
    Posted 4 years ago #

    Since wp_list_categories is defined in the category-template.php file in the wp-includes folder, could you please instruct what code to add/delete and where to do so in the category-template.php file in order to exclude listing of child category posts from parent list of posts.

  7. MichaelH
    Member
    Posted 4 years ago #

    Dstall - start another thread with your last two questions please.

  8. DStall
    Member
    Posted 4 years ago #

  9. Gouri
    Member
    Posted 4 years ago #

    I am facing a similar problem on my travel destinations site. Parent category, 'travel destinations' does not contain any post but when it is clicked, it lists all posts under its child categories.

Topic Closed

This topic has been closed to new replies.

About this Topic