Only show posts from one category (but show all pages)
-
I’m trying to hide all posts except one category on the main page. My problem is that the index.php code is also used for calling all my pages as well. I’m currently using the following code…
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if (in_category(‘5’)&& is_home()) continue; ?>
<?php if (in_category(‘6’)&& is_home()) continue; ?>My problem is that each new post category means that I have to make another line to exclude it from the home page. I’d rather have an “opt in” function like this one I tried before…
<?php query_posts(‘cat=12’); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>The problem with coding this way (although I do get the correct result on the home page) is that EVERY page I attempt to view now only shows POSTS of this category and not the PAGES since I have not modified the main index page that all the subsequent pages are made from. Is there a way to exclude all but one category of posts from the home page and still manage to render other page views on different pages and not have the same result?
- The topic ‘Only show posts from one category (but show all pages)’ is closed to new replies.