[resolved] Exclude posts from a category on the homepage?? (6 posts)

  1. DDT
    Posted 9 years ago #

    hi all,

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


  2. Chris_K
    Posted 9 years ago #

    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.

  3. DDT
    Posted 9 years ago #

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

  4. Chris_K
    Posted 9 years ago #

    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.

  5. DDT
    Posted 9 years ago #

    @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.


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

  6. Chris_K
    Posted 9 years ago #

    There's a little pulldown at the very top of this thread. Just change it to "Resolved"

Topic Closed

This topic has been closed to new replies.

About this Topic