Support » Fixing WordPress » Exclude more than one category?

  • 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 ( and how to exclude categories from being listed in the category list (, 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?

Viewing 8 replies - 1 through 8 (of 8 total)
  • TechGnome



    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.

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

    /* 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
    /* --------------- */

    Another question:
    I’ve been trying to use wiki’s exemple – – but it’s not working on WP 1.2.
    Did anyone get success?

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

    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 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?


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

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

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

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Exclude more than one category?’ is closed to new replies.