Exclude Categories not working for pages.
-
Hey everyone,
So here’s the scenario.
I have an open-registration forum, and I’ve forced posts from all non-admin users to one of two categories. These two categories, just for context, are ‘Journals’ (18) and Press Releases (45). Now, my theme uses a portal page (home.php) and utilizes index.php for single posts.I also have a “blog” page (page_blog.php, /blog).
Following so far?
OK, so I’m using a combination of recent-posts plugins to display the latest posts from categories 18 and 45 in one of my sidebars. I want to exclude those categories from home.php and page_blog.php, however.Just using Advanced Category Excluder (plugin) effectivley blocked the categories from those places, but, unfortunately, it also blocked them from appearing ANYWHERE on the page (including in the recent posts widgets).
So, I figured what I had to do is exclude the categories only in the loop. I was going to use in_the_loop(), but it turns out I was wrong! For some reason that I don’t understand, I only have to use the following:
<?php query_posts($query_string . ‘&cat=-18,-45’); ?>
Works like a charm for home.php — the categories still display in the widgets.
Unfortunately, that same code doesn’t work on the blog page!
When i used that code, page_blog.php shows ZERO articles; it excludes EVERY category.Here’s the unmodified code as in page_blog.php:
<?php $wp_query = new WP_Query(array('cat'=>ot_option('blog_cat'),'showposts'=>ot_option('blog_cat_num'),'paged'=>$paged)); ?> <?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?> <?php global $more; $more = 0; ?>
Any suggestions?
- The topic ‘Exclude Categories not working for pages.’ is closed to new replies.