Thread Starter
somtam
(@somtam)
I notice that it works only if I insert in the args a specific
“category_name” => “the name”
or
cat = N of categories
this doesn’t make sense to me…
PS: only with from the last 3.8 version.
Does something change from that?
how many ‘sticky’ posts do you have?
what is the full code of the query?
Thread Starter
somtam
(@somtam)
Hi and thanks for helping!
I make a simple test in a page, and the code is:
$query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 2,
)
);
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
the_title();
echo '<br>';
}
}
wp_reset_postdata();
if I add the ‘category_name’ or ‘cat’ everything is working fine…??!!??
Thread Starter
somtam
(@somtam)
I tried to add
'ignore_sticky_posts' => true,
and now the number of posts returned is ok.
This stuff let me full of doubts… does it means that for a widget or a plugin that uses WP_Query and posts_per_page we have always to use ignore_sticky_posts?
I’m having the same problem. A sticky should not add posts to the posts_per_page count. Is this a WordPress bug?
Thread Starter
somtam
(@somtam)
As they say in the wp_query page:
ATTENTION If you use sticky posts, they will be included (prepended!) in the posts you retrieve whether you want it or not. To suppress this behaviour use ignore_sticky_posts
so probably we have to ad ignore_sticky_posts always if we need the exact number of row to be retrieved.