Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to create a loop that excludes a category and only displays a certain number of posts per page.

I have tried both have_posts and query_posts to do this, but I'm a bit stuck on the most effective method. What would you use to do this?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Just use a custom query like this:

$exclude_cats = '2,52,3';
$posts_per_page = '4';
$loop = new WP_Query("category__not_in=$exclude_cats&posts_per_page=$posts_per_page");
    while($loop->have_posts()): $loop->the_post();
        //Do stuff here the_content(), the_title() etc...
    //Do something here
share|improve this answer

Your Answer


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.