Hide / Exclude Categories From Posts Page
-
I have my blog setup with a static homepage and the blog index displays on a page called “blog” (https://nnmportfolio.com/blog). I have a category called “photography” for which I recently created a separate website. As a result, I’d like to hide the photography category and its posts from the category list and blog pages but I don’t want to delete or prevent access to posts.
Given that’s its only one category I would prefer to use code rather than a plugin. I tried searching the forums and elsewhere online but the instructions and codes that I found (see below) didn’t work and I don’t have much knowledge of PHP. I’d greatly appreciate any suggestions. Thanks!
Code #1
<?php if (is_front_page() && !is_paged() ) $posts = query_posts($query_string . '&cat=-35'); ?>
Code #2
<?php $cat_to_exclude = 35; query_posts($query_string . '&cat=-'.$cat_to_exclude'); ?>
Code #3
<?php if (in_category('35')) continue; ?>
- The topic ‘Hide / Exclude Categories From Posts Page’ is closed to new replies.