Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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

share|improve this answer
    
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 '11 at 1:43
    
Also is there a way to exclude categories by nicenames not ids? –  Jiew Meng Feb 19 '11 at 1:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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