WP_Query: Why is sticky post not first item in loop?
-
I’ve got a custom WP_Query loop based of meta_value variables:
$meta_cat = get_sub_field('category'); $posts = new WP_Query( array( 'cat' => $meta_cat, 'posts_per_page' => get_sub_field('recent_ppp'), ) );
But somehow when I’ll make a post sticky it isn’t shown as the first item in the while loop.
I know
ignore_sticky_posts
is default set to false so I won’t bother changing it. Also tried looking in de order_by documentation if some value is related to sticky post but it isn’t.Although The
order_by => 'post__in'
might be close:Preserve post ID order given in the post__in array
But when I set
post__in => get_options('sticky_posts')
only the sticky post is showing.Is this even possible without building two custom loops (one handeling the sticky posts and the other for the other posts? That would be really bad, because not all categories contain sticky posts.
- The topic ‘WP_Query: Why is sticky post not first item in loop?’ is closed to new replies.