Excluding Category From Main Page?
-
I want to exclude a certain category from my main page. I looked in the Docs and found this:
If you need to exclude a category from the front page, you can place code that does the exclusion inside The Loop of your theme's index.php file.
The Loop starts something like this:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
To exclude category 4 from the front page, just inside The Loop, add this condition :
<?php if ( !(in_category('4')) || !is_home() ) { ?>
<!-- Output the post here -->
<?php }>
This means that if on the front page, the post will be presented if it's not in category 4. On pages other than the front ( home ) page, all posts are presented.
————————-
But I’m not sure where exactly to put their piece of code. Any suggestions?
- The topic ‘Excluding Category From Main Page?’ is closed to new replies.