WordPress.org

Forums

[resolved] Hide categories from main page (5 posts)

  1. gvforces
    Member
    Posted 6 years ago #

    How can i hide certain posts from an entire category from displaying on my main page ? i have no idea about coding i saw a few plugins but none were compatible with my version of wordpress

  2. buddha trance
    Member
    Posted 6 years ago #

    On index.php of your theme, right after

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

    you add the following

    <!-- If the post is in the category we want to exclude, we simply pass to the next post. -->
    <?php if ($postnum == 1 ) { ?>
    
    // My content
    
    <?php } ?>
     <?php if (in_category('3')) {$postnum = 0; continue; }
     ?>

    where 3 is an example and you replace it with the appropriate category number.

  3. gvforces
    Member
    Posted 6 years ago #

    that worked for one category but what if i want to exculde more than one categories ?

  4. gvforces
    Member
    Posted 6 years ago #

    nevermind i worked it out thank you

  5. gariben
    Member
    Posted 6 years ago #

    thanks for the help.

    I'm going to try it out too.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.