The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

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

  1. gvforces
    Posted 7 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
    Posted 7 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
    Posted 7 years ago #

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

  4. gvforces
    Posted 7 years ago #

    nevermind i worked it out thank you

  5. gariben
    Posted 7 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


No tags yet.