Support » Fixing WordPress » Exclude posts from a category on the homepage??

  • Resolved DDT

    (@ddt)


    hi all,

    Wondering if there is an easy way to exclude posts from a category?

    Regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • Here’s one way, there are quite a few…

    Find this line within the loop in your main index.php file:

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

    Just after that line, paste this line (change the 14 to your category ID number):

    <?php if ( !(in_category('14')) ) { ?>

    After that, you will then need to find this line:

    <?php endwhile; ?>

    And just before that line, paste this:

    <?php } ?>

    Cheerfully lifted from http://codex.wordpress.org/Adding_Asides.

    hmm, I see what you mean and it works for excluding the category but now it never shows.

    I mean even when I click the category navigation it doesn’t show the posts or when I point to a specific post within that category. Any suggestion how to fix this??

    It sounds like your theme only has the index.php?

    Have a look at Template_Hierarchy. I’d suggest making a category.php page, essentially as a copy of your index.php, but without the filtering.

    @handysolo, tx you help me out quit good

    Indeed I have only the index.php

    I added up using
    if (in_category(‘6’) && is_home() ) continue;

    and a category-6.php file.

    tx,

    ps: how to put a resolved tag on this thread??

    There’s a little pulldown at the very top of this thread. Just change it to “Resolved”

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude posts from a category on the homepage??’ is closed to new replies.