WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm going crazy...

<?php query_posts(array('cat' => 3, 'posts_per_page' => 1)); ?>

This shows 1 post (there is two in the category) >> OK

<?php query_posts(array('posts_per_page' => 1)); ?>

This shows 4 posts (there is four in the whole database) >> WTF? :P

This is crazy... or am I ?

Note: I only have one loop (this one), in this template.

share|improve this question

If you want to change your array to exclude sticky, then this should work

get_posts( array( 'post__not_in' => get_option( 'sticky_posts' ), 'posts_per_page' => 1 ) );

share|improve this answer

You are calling an array with only one paramater. Change your code to: <?php query_posts('posts_per_page=1'); ?>

share|improve this answer
Thx Rachel. Well, it doesn't work either :) But I know why. This thing has been driving me nuts for hours now. Guess what, all my posts are set as "sticky"... but I don't know how to work around that... Any idea? – flintsburg Nov 22 '11 at 19:55
This query should work with sticky or non-stick posts: query_posts('showposts=1'); – Rachel Baker Nov 22 '11 at 19:59
Actually no, it shouldn't (but yes, this is weird/silly). You have to use caller_get_posts=1 to exclude sticky posts from being returned at the top of your query results... – flintsburg Nov 22 '11 at 20:02
You may want answer the question for me please, as I'm a noob (not enough reputation yet), I can't. Thx :) – flintsburg Nov 22 '11 at 20:04
Clarification question: did showposts=1 not display any posts at all? – Rachel Baker Nov 22 '11 at 20:19

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.