I am using the Boldy theme from Site5 on a v3.1.2 site.

The way this theme works, is that there is a portfolio, (which I am using as a case studies gallery) that pulls in posts from a specific category you define under the themes settings (id=98)

This is fine if you also set the blog up as per the Boldy instructions, where all blog posts come under a category called blog, but this wasnn't going to give me the slugs I wanted, so I adopted to use a static page called blog to show my posts on.

This all works fine, apart from the fact that the posts I create for my portfolio/case studies gallery (category = case studies) now appear in my blog as well.

Is there a way to hide posts within a specific category within the blog, but for it not to have the same affect in my case studies gallery?

--EDIT-- With some help from Wyck via the comments, made some progress. Here is a txt version of my themes default index.php file.

If I insert the following onto Line 2:

<?php query_posts($query_string . '&cat=-98'); ?>

= This results in no posts being shown on my Downloads page, but all posts still appearing on my Blog page.

I need the vice versa of this. I am sure I am close, but perhaps I need to modify which line I put this on?

--EDIT x2-- Now using the download monitor for my downloads gallery. But using the portfolio for my case studies. So some of the links above have changed, but the problem is exactly the same.

  • So you don't want downloads to appear on your main blog -- is that what you're saying?
    – ZaMoose
    Commented Apr 27, 2011 at 13:39
  • Yes that is correct. In the long run, ill be also using the portfolio for a 'case studies' page. Therefore ill also need to exclude case study posts from the blog page.
    – jakc
    Commented Apr 28, 2011 at 4:24
  • what you want can be achieved by modifying the query to exclude a particular category but I am not sure of the code to modify it, it will probably be 4-5 lines
    – Ashfame
    Commented Apr 28, 2011 at 7:52
  • ok I think I have got it working, will post an answer soon. I need to study your question what behavior do you exactly want it to do on various pages.
    – Ashfame
    Commented Apr 28, 2011 at 8:21
  • @simon Take a look at my answer and let me know if it does what you want
    – Ashfame
    Commented Apr 28, 2011 at 8:29

5 Answers 5


You want the category 98 to be excluded only on the blog page, right? They should be accessible on the category page directly (your downloads page), correct?

Can you try this? Let me know if its not what you want, we can modify it to suit your needs. Right not it only excludes the category on where you show your blog posts.

add_action('pre_get_posts', 'block_cat_query' );

function block_cat_query() {
    global $wp_query;   
    if( is_home() ) {
        $wp_query->query_vars['cat'] = '-98';
  • This has worked! Im going to hold off marking this as an answer until ive done some full testing. Thanks loads Ashfame.
    – jakc
    Commented Apr 28, 2011 at 9:55
  • Great! As a test checkout the different pages where you want those particular posts to be shown or not to be shown and let me know :)
    – Ashfame
    Commented Apr 28, 2011 at 10:16
  • @Simon Great! You didn't even bother to take a few secs to award the bounty.
    – Ashfame
    Commented May 4, 2011 at 15:41
  • I thought marking the anser as resolved awarded u the bounty?
    – jakc
    Commented May 5, 2011 at 10:49
  • Sorry man, ive flagged for a moderator to re-direct the bounty to you. Its first time ive made use of the bounty feature. I figured it went to the one I marked as the answer
    – jakc
    Commented May 5, 2011 at 10:50

In Settings -> Reading if your Front Page is not set to show "Latest Posts" whatever is selected as posts page will use the index.php template.

I do use a static page, but I think it still uses index.php to populate items on this static page? I checked by fiddling some free text in index.php and it was reflected in the blog posts on the static page. – Simon 4 hours ago

Your comment is correct your "static page" is using index.php

To use a static page with a custom template for your blog post change your reading settings as follows:

Change This:

enter image description here

To This:

enter image description here

For your custom template just copy and paste index.php to create a new file and name it custom-page-blog.php and add this to it.

Template Name: Blog
                'category__not_in' => 98
                $blog_query = new WP_Query( $args );
             while ($blog_query->have_posts()) : $blog_query->the_post(); ?>        
            <!-- Begin .postBox -->
            <div class="postItem">
                    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1> 
                    <div class="meta">
                                <?php the_time('M j, Y') ?> &nbsp;&nbsp;//&nbsp;&nbsp; by <span class="author"><?php the_author_link(); ?></span> &nbsp;&nbsp;//&nbsp;&nbsp;  <?php the_category(', ') ?>  &nbsp;//&nbsp;  <?php comments_popup_link('No Comments', '1 Comment ', '% Comments'); ?> 
                    <?php the_content(__('Read more >>')); ?>   
            <!-- End .postBox -->
            <?php endwhile; ?>
                <!--<div class="navigation">
                            <div class="alignleft"><?php next_posts_link() ?></div>
                            <div class="alignright"><?php previous_posts_link() ?></div>
                <?php if (function_exists("emm_paginate")) {
                } ?>
            <!-- End #colLeft -->
    <?php get_sidebar(); ?> 
    <?php }?>
    <?php get_footer(); ?>

Go to your static "Blog" Page and select the new template in page atributes.enter image description here

  • Thanks for this. However, im not sure how this solves the problem? The new template file will still need tweaking to remove a category from it? Why dont we just do this to the index.php? Also where you tell me to add that php line, to me it looks like you have opened a php tag but not closed it?
    – jakc
    Commented Apr 28, 2011 at 9:09
  • @Simon I edited the answer and included the whole custom-page-blog.php template. This template will show all the posts not in category 98.
    – Chris_O
    Commented Apr 28, 2011 at 9:25
  • Really appreciate your efforts here. You approach does look like it will work, however, Ashfame's answer does not require me to create a new template file, so would appear to be better? Still testing...
    – jakc
    Commented Apr 28, 2011 at 9:59
  • His approach is great and much simpler. Choose what works best for you.
    – Chris_O
    Commented Apr 28, 2011 at 10:01

It's difficult to tell since you supplied no code but removing a category from your blog loop is typically very easy.

For instance above the main loop, if your category "portfolio" has an id=12 :

query_posts( 'cat=-12' );
  • Which php file will this be in? Ive done a search for 'query_posts' in all PHP files in my theme and cant find it.
    – jakc
    Commented Apr 17, 2011 at 3:32
  • query_posts alters the "main loop" of your blog (usually index.php), you will have to add it yourself. codex.wordpress.org/The_Loop
    – Wyck
    Commented Apr 17, 2011 at 4:52
  • Thanks, been reading up on this. Q1 - How do I find out what ID a category is? Do I need to dive into the database tables? Q2 - My theme has its own index.php. Still not too sure which line to place the query_posts in: dekho.com.au/index.txt
    – jakc
    Commented Apr 18, 2011 at 9:14
  • 1
    The easiest way to find the category ID is to click your category in Admin and just hover over one and you will see the ID on mouseover or in your browser ( in Chrome it shows at bottom ).
    – Wyck
    Commented Apr 18, 2011 at 13:37
  • Hi Wyck. I found out that the category I want to exclude is 98, but I have not been able to fit it in the right place in my index.php file (see above link to see the code for this file) Any ideas?
    – jakc
    Commented Apr 27, 2011 at 3:56

Why don't you use something like WordPress Download Monitor?

  • Ill have a look at this. Although still need my orig Q answered, as ill be using the portfolio template again for a category for Case Studies, so will still need to know how to exclude that category from the blog, and only the blog.
    – jakc
    Commented Apr 28, 2011 at 3:23
  • Im now using this for my downloads. However, as per the edits in my Q, I am using the portfolio for my 'case studies' Same problem persists where case studies show up in blog.
    – jakc
    Commented Apr 28, 2011 at 7:16

if you use static page to show the blog post, add the wyck's code to template that used for that page.

  • I do use a static page, but I think it still uses index.php to populate items on this static page? I checked by fiddling some free text in index.php and it was reflected in the blog posts on the static page.
    – jakc
    Commented Apr 28, 2011 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.