[wp-hackers] WP_Query and sticky post (Twenty Eleven)

Tommy Leunen tom at tommyleunen.com
Thu Jul 14 01:02:13 UTC 2011


I made a little test with sticky post (featured post) in the new Twenty
Eleven theme, and I notice something strange.

Here is the code that retrieve the data :

$featured_args = array(
'post__in' => $sticky,
'post_status' => 'publish',
'posts_per_page' => 10,
'no_found_rows' => true
$featured = new WP_Query( $featured_args );

With more than 10 featured post, the condition "posts_per_page" is not
respected. I have more than 10 featured post on my showcase page. So I
decided to add a new argument "paged" to my query, to specify the page I

For example, if I have 12 featured posts, and a paged = 2, it only shows 2
posts. So that's correct. But if I have paged = 1, it shows me all the
featured post, and not only 10.

I made some other test, and the bug only appears when paged = 1, which is
the default value.
Is there a bug in the system ? Or I made something wrong ?



More information about the wp-hackers mailing list