I have set my home page to use a static template. So I created a Blog page to use a blog template to render my blog posts. The problem is it just renders the page content. I want it to render blog posts. Minus that of category "portfolio" & "WIP". Do I need to create a custom query_posts? what might it look like. To simulate what I get by default if my home page is set to latest posts. I will also need pagination to work.

1 Answer 1


if you want to exclude categories then you do need to create a custom query something like this:

$page = (get_query_var('paged')) ? get_query_var('paged') : 1;    
query_posts( array( 'category__not_in' => array( 2, 6 ) , 'paged' => $page ) );

just above the loop and change 2 , 6 to the category ids which you want to exclude , and to help keep pagination i would add wp_reset_query(); just after the loop to save later problems.

keep in mind that this is probably the simplest form of the query_post you need but if you want more out of its power take a look at the codex.

Hope This Helps

  • I saw the codex and actually wondered if I need to add publish = true posttype = post etc for example. They are the defaults but I wonder since its a page, and the query_posts looks more like posttype=page&page=x I need to re-specify the params
    – Jiew Meng
    Feb 19, 2011 at 1:43
  • Also is there a way to exclude categories by nicenames not ids?
    – Jiew Meng
    Feb 19, 2011 at 1:44

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.