Ignore sticky posts if post is not in meta query
-
Hi all,
I have such a wp query args:
$args = array( 'post_type'=> 'myposttype', 'posts_per_page' => 10, 'meta_query' => array( 'relation' => 'AND', array('key' => 'routeFrom','value' => 'rome','compare' => 'LIKE'), array('key' => 'routeTo','value' => 'paris','compare' => 'LIKE'), ) );
Each my post has custom field routeFrom and routeTo. In this example if routeFrom equal to Rome and routeTo equal to Paris wp query displaying those posts.
The problem is that sticky posts appear no matter what meta query i’m using.
I want to display particular sticky posts if they only match meta query.
Real life example would be: I have a route search page where i would like to display sticky post on top of all posts, but only if it ALSO meets meta query (in this case particular route).
I’m using sticky posts plugin “Sticky Custom Post Types”, but posts are stored in the global ‘sticky_posts’ option field, just like regular posts.
Any help?
- The topic ‘Ignore sticky posts if post is not in meta query’ is closed to new replies.