• 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?

Viewing 1 replies (of 1 total)
  • Are you using a Static Front Page with a blog page? If so, your template is not being used.

    From the Codex: Settings Reading SubPanel:

    Posts page – Select in the drop-down box the name of the Page that will now contain your Posts. If you do not select a Page here, your Posts will only be accessible via other navigation features such as category, calendar, or archive links. Even if the selected Page is Password protected, visitors will NOT be prompted for a password when viewing the Posts Page. Also, any Template assigned the Page will be ignored and the theme’s index.php (or home.php if it exists) will control the display of the posts.

    I like to put in an HTML comment like <!-- page_blog.php --> in my templates so I can look at the source of a page to see what template is being used.

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude Categories not working for pages.’ is closed to new replies.