• Resolved gvforces

    (@gvforces)


    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • buddha-trance

    (@buddha-trance)

    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.

    Thread Starter gvforces

    (@gvforces)

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

    Thread Starter gvforces

    (@gvforces)

    nevermind i worked it out thank you

    thanks for the help.

    I’m going to try it out too.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hide categories from main page’ is closed to new replies.