WordPress.org

Ready to get started?Download WordPress

Forums

Exclude more than one category? (9 posts)

  1. meko
    Member
    Posted 9 years ago #

    I have been searching for a way to exclude more than one category of posts from displaying on the index page.
    I found a way to exclude one category (http://faq.wordpress.net/view.php?p=55) and how to exclude categories from being listed in the category list (http://faq.wordpress.net/view.php?p=56), but both aren't what I'm looking for. I am converting from MT, and I am looking for a way to replicate what the MTCatEntries plugin offered.
    For example, for categories A, B, C, D and E, I only want posts from category A, C and E to be displayed on index page (and archives, too if that's also possible).
    Any suggestions?
    Thanks!

  2. TechGnome
    Moderator
    Posted 9 years ago #

    Instead of excluding categories, try including jsut ones you do want:

    If (!isset($cat) ) {
    $cat = "1,3,6,7"; // Where 1,3,6,7 represent the IDs of the cats you DO want to show
    }

    This will work for the main page, not sure how it affects archives tho.
    TG

  3. fabioassis
    Member
    Posted 9 years ago #

    TechGnome, where should I put this code? Oh, nevermind, I found it

    <?php
    /* Hack - show just a few categories */
    If (!isset($cat) ) {
    $cat = "1,3,6,7"; // Where 1,3,6,7 represent the IDs of the cats you DO want to show
    }
    /* --------------- */
    require('wp-blog-header.php');
    ?>

    Another question:
    I've been trying to use wiki's exemple - http://www.wiki.wordpress.org/ShowOneCategory - but it's not working on WP 1.2.
    Did anyone get success?

  4. fabioassis
    Member
    Posted 9 years ago #

    By the way, thank you very very much, TechGnome. Your code saved my day. :)

  5. twuks
    Member
    Posted 9 years ago #

    I want to exclude just one category from showing on the front page (I have a plugin that shows that category on the sidebar, so it shouldn't appear on the main) I've tried hacking my-hacks.php and I've also tried http://faq.wordpress.net/view.php?p=55 but what they both seem to do is showing ALL the posts in the other categories. So I end up with a huge list of entries on my index page. Does anyone have a solution for this?

  6. twuks
    Member
    Posted 9 years ago #

    Anyone?

  7. Java
    Member
    Posted 9 years ago #

    This was just what i was looking for fabioassis it worked like a charm! Thank you so much! :-)

  8. Java
    Member
    Posted 9 years ago #

    And thats TechGnome for showing us the part that needed to be added.

  9. indiaberry
    Member
    Posted 7 years ago #

    Thanks for this, I am going to try this one out now. I am glad I didn't have to start a new thread.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.