WordPress 2.0 ‘No SubCats’ Plugin: Take Subcategory Posts out of Category pages

WordPress 2.0 ‘No SubCats’ Plugin: Take Subcategory Posts out of Category pages



I thought it was bad form to have a category page that included subcategories. With all that, it was a mess.

After all, subcategories get their own page! Those posts don’t need to be in both places!

So I needed to filter out subcategories.

See all of our WordPress Plugins

And I couldn’t just filter them out of archive.php … that disturbed the number of posts per page, sometimes leaving continuation pages with nothing on them! We needed to change the query.

This plugin solved the problem for me; I hope it helps you, too.

It works great with the Category Visibility plugin (our version).

It works fine with the Fold Category List plugin as long as you have a Post in the parent category. Otherwise the subcategory links will not appear in the sidebar. While this does not actually affect the performance of NoSubCats, It makes the page links unavailable.

It might not play well with some other plugins or some themes.

For WordPress 2.0.x only

Instructions

  1. Simply download and unzip it.

  2. Put it in your plugins directory.

  3. Activate it.

Download

Version 0.3: Download

Version Log

Version 0.3: Corrects for behavior change in WP 2.1 detecting Admin pages.

Version 0.2: Corrects for behavior change in WP 2.0.5 detecting Category ID.

Version 0.1: Initial release for WP 2.0.4.


23 Responses to “WordPress 2.0 ‘No SubCats’ Plugin: Take Subcategory Posts out of Category pages”

  1. Vishal Says:

    Works great! Thanks!

  2. tino schramm Says:

    thx ….

  3. Mo Says:

    Hmmm…works only if min. one Post is in the displayed cat. Otherwise i get a 404. :(

    Mo

  4. William J Hines Says:

    Beautiful plug - in. EXACTLY what I was looking for. Thanks for this contrib!

  5. Mookie Says:

    This is not working for me. I have ‘Category Visibiliy’ also running (works great!) but this part is not working (as i understand it).

  6. angela Says:

    hi, thanks for this very nice plugin! It works for me, of course. Can you tell me how to change the code so that the plugin does NOT effect on 1 or 2 certain cats?

  7. bas Says:

    Category Visibility works great. NuSubCats is another thing I was looking for. However, I can’t find were to switch on and of the subcategories. It might be a bug, but more likely I’m just blind. Can you help me with this?
    Regards,
    Bas

  8. Portable Gadgets Says:

    Hi man, I recently download this plugin and want to say you that he is good, but I have same question that bas from previous comment. Can you help me too?

  9. Rich Says:

    If it’s going to work for you, the subcategories will disappear from the parent page simply by activating the plugin. As per instructions above.

  10. SEO Blogger Says:

    Hey, it seems that when I choose to show the ‘number’ of posts in the parent category, the parent category displayed is 1 more than the number of posts indicated — due to the filtering of your NoSubCat plugin.

    Hope, you can get this plugin update, since having a post in the parent AND subcat is one of my ‘big’ pet =P. This results in duplicate content, as you may know it. Anyway, hope this plugin will get developed more.

  11. Brian Carnell Says:

    Awesome job on this plugin.

  12. Brian Carnell Says:

    Does anyone know if this still works with WP 2.3?

    Thanks.

  13. tkhobbes Says:

    No it is apparently NOT working with Wordpress 2.3! I got weird error messages complaining about the table wp_post2cat being not present when it was activated. Sad enough - the plugin was very good…

  14. Brian Carnell Says:

    Are there any plans to update this so it works with Wordpress 2.3?

    Thank you,

    Brian

  15. Rich Says:

    Sorry, no plans for 2.3… I can’t complain that WP is advancing but I’m sticking with 2.0 because I’m unable to keep up with the changes.

  16. Blakey Says:

    Works great, many thanks!

    Andy

  17. Güzel Kadın Says:

    Are there any plans to update this so it works with Wordpress 2.3?
    Thank you
    Güzel Kadın

  18. Craig Heimburger Says:

    If you’re rockin’ WordPress 2.3 and looking for a solution to keep subcategory posts off your page, I can suggest to you a non-plugin approach:

    In the Archive.php file of your theme, looking inside of ‘the loop’, just after the

    What you want to do is create a IF STATEMENT to see if the posts that are about to be displayed are actually of that category, or not.

    I’m doing this with a piece of code that looks like this:

    The full markup, though rough, works great on both category and tag pages (and the such):


    ” title=”Read “>

          <div class="text-body"><?php the_content() ?></div>
        <?php } ?>
        <?php if ( in_category($cat) ) { ?>
          <h2><a href="<?php the_permalink() ?>" title="Read <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
          <div class="text-body"><?php the_content() ?></div>
        <?php } ?>
    

  19. Craig Heimburger Says:

    Well, even though I used the CODE tags, things didn’t turn out. You can still see the

    if ( in_category($cat) )

    statement though… good luck

  20. Matteo Raggi Says:

    Thi look to be super useful?
    what about compatibility with WP 2.3.2 ?
    where I can find a demo of this plug in in action?

  21. Matteo Raggi Says:

    I have installed this plugin here: http://www.gioielleriaforli.it/
    using wp 2.3.2 uploaded and activated, put nothing happen, what I must do now?

  22. Rob Schumann Says:

    Hi,

    Fold Category List can and does support the display of category links where those categories do not contain posts, however not by default. This is in keeping with the old wp_list_cats tag, which also by default does not include empty categories in the category list.

    Turning display of empty categories on requires setting ‘hide_empty=0′ in the arguments.

    Fold Category List was recently updated (January 2008) to support the WP 2.3 family and can be downloaded from www.webspaceworks.com/resources/wordpress/31/

  23. Richard Says:

    Can someone please give an update to show how to exclude sub-cat posts from the archive pages with Version 2.5?

    Thanks

Leave a Comment


Comments are accepted under the Submissions policy in this website’s Terms of Use.

Get our ‘Minute of Magic’ Newsletter! FREE!

Name: Email: