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.


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 ) );

| improve this answer | |

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

| 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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