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'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
add comment

2 Answers 2

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
add comment

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
show 1 more 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.