WordPress.org

Ready to get started?Download WordPress

Forums

Request: Hide Posts in Child Categories (16 posts)

  1. mystifier
    Member
    Posted 3 years ago #

    For years, I have used a plug-in to hide posts in child categories so that only posts for the current category show.

    This has stopped working after a recent update and my sites now look awful. I haven't managed to find a replacement plug-in that works (only others that have also recently stopped working).

    It seems to me that this should be core behaviour but at the very least, PLEASE can you consider a 'Hide Child Posts' option.

  2. Which plugin were you using?

    The in_category conditional might be a better approach than a plugin:

    http://codex.wordpress.org/Template_Tags/in_category

  3. mystifier
    Member
    Posted 3 years ago #

    I have used 'Kinderlose' for years (http://guff.szub.net/2007/11/30/kinderlose/)
    This was a simple add_filter('posts_where', 'kinderlose_where');

    And 'Post Category Only' worked fine (http://wordpress.org/extend/plugins/post-category-only/)
    which added a class post_category_only

    Now neither have any effect and I can't find one that works.

    This is a big failing in wordpress; showing all child category posts on large sites is a crazy idea; being able to hide them as an option at least would be a massive God-sent.

  4. Are you trying to only show posts from the parent category in an archive type page or are you trying to list all the parent categories?

  5. mystifier
    Member
    Posted 3 years ago #

    When a category is selected, I only want posts to show for that category... not also posts for every single child (sub)category.

    I have exhausted plug-ins so a hack would be greatly appreciated.

  6. Easiest way is by using a Category Template.

    http://codex.wordpress.org/Category_Templates

    Basically you want to have a category.php page, and then change
    <?php while ( have_posts() ) : the_post(); ?>

    to this
    <?php while (have_posts()) : the_post(); if (in_category($cat)) { ?>

    and
    <?php endwhile; ?>

    to
    <?php } endwhile; ?>

    See http://motioncity.com.ar/2008/wordpress-tip-how-to-exclude-children-categories-on-a-template/ for mroe details

  7. mystifier
    Member
    Posted 3 years ago #

    Thanks Ipstenu, but I can remember trying this a long time ago.

    Although my template Main Content area is very simply

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    ....
    <?php endwhile; ?>

    After the mod, top-level categories show empty.

    I am not sure if this is a problem with my also using another category related plug-in: http://www.webspaceworks.com/resources/cat/wp-plugins/31/

    Very frustrating!!

  8. Then it would be like this:

    <?php if (have_posts()) : while (have_posts()) : the_post(); if (in_category($cat)) { ?>
    
    ...
    
    <?php } endwhile; ?>

    That plugin shouldn't matter.

  9. mystifier
    Member
    Posted 3 years ago #

    That's exactly what I have but it doesn't work.

    EXAMPLE: http://www.burtongrammar.co.uk

    Select: School Staff >> (Life & Times Menu)
    The ONLY post in this category is http://www.burtongrammar.co.uk/?p=134
    That is ALL that showed before the update; now I get pages and pages of mis-ordered posts from all lower sub-categories

    Select: Bond Street (Theme)
    This has the mod applied. I get nothing in top-level menus (categories)!!

    I didn't notice that things were so bad before I updated all websites, including the linked http://www.burton-on-trent.org.uk

    My kids school website, which has four or five level deep sub-categories is a total mess with EVERY child-category showing at the top level.

    WordPress might be okay for small blogs but suddenly, every website is completely unusable.

    (Same applies to Admin, Filter Posts by Category is a total mess now again showing pages and pages of EVERY child-category).

  10. mystifier
    Member
    Posted 3 years ago #

    I don't have $cat. I think it needs to be a call to get the current category, something like:

    if(in_category(get_current_category())){

    (which doesn't work but I can't figure out what does).

  11. WordPress might be okay for small blogs but suddenly, every website is completely unusable.

    Tell Time that. It IS usable, but this is more of a themeing question, and I'm afraid I'm not the best at that.

    Maybe try the code from this: http://jivstudio.com/2010/12/02/show-only-parent-categories-on-wordpress-archives/

  12. mystifier
    Member
    Posted 3 years ago #

    Nothing there that helps I'm afraid but I am grateful for your continued help.

    Plug-ins that hide child category posts have always been extremely popular and high download. This is because on websites where there are three or four levels of sub-category, it can soon result in many tens of posts showing unnecessarily at higher (hierarchical) levels. Without a plug-in, or better still, core fix, large websites ARE completely unusable.

    I have seven or so different wordpress sites and I can't think of one example where this is sensible core behaviour and not having an option to hide them at least is very poor.

    The two websites given as examples receive in the order of 10000 pageviews/month, suffice to say that since I upgraded, I have received twenty-odd emails 'informing' me that the site navigation has stopped working.

    I can't fix it and it is enough reason to wind back to an old version where plug-ins work again.

  13. Plug-ins that hide child category posts have always been extremely popular and high download.

    Except all the ones you cite aren't on the WP repository... Which is really odd and seems to contradict what you're saying.

    More to the point, I think that people aren't using categories to that degree anymore, and mostly due to the advent of tags. I have four categories on a pretty large site, and the rest is all sorted with tags in each category, or Custom Post Types. It's an organizational shift, but I found people couldn't FIND things if I had a surplus of categories.

    Still, I would post that question 'How do I hide child categories in a category archive page?' in the template section, where the much smarter template people live :) I'm sure this is stupid easy, but it's not my forte.

  14. Kafkaesqui

    Posted 3 years ago #

    I just updated Kinderlose, and tested it on 3.1.3. Let me know if there's any problems with it.

  15. aj1234
    Member
    Posted 3 years ago #

    How about "exclude_pages" plugin? It works on pages, I don't know about posts.

  16. mystifier
    Member
    Posted 3 years ago #

    In the end, I figured out the field name change but in my original plug-in. This has been updated for 3.1+ by the author and is a very elegant solution:

    http://guff.szub.net/2007/11/30/kinderlose/

    Simple but essential!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.