WP Query – Posts Per Page not working in combination with category__in

I’m not sure whether it’s a bug or i’m doing something wrong, but it doesn’t seem like posts_per_page works at all when using category__in.

My query is below, even though I’ve set posts_per_page to 1, it’s still showing all posts.

$posts = new WP_Query(array(
‘post_type’ => ‘post’,
‘category__in’ => wp_get_post_categories($post->ID),
‘posts_per_page’ => 1,
‘post__not_in’ => array($post->ID)
));

Any ideas?

Read more here:: WP Query – Posts Per Page not working in combination with category__in

Leave a Reply

Your email address will not be published. Required fields are marked *