only first part of meta_query works
-
Hi,
I’ve got a meta query with two queries and a AND relation. But somehow it’s not working. I discovered only the first part is executed. So, I must have an error somewhere.
This is my code:
$today = getdate(); $tax_query = array('relation' => 'OR'); $post_ids = array(); $args = array( 'post_type' => 'wmw_activities', 'posts_per_page' => 6 , 'relation' => 'AND', 'orderby' => 'rand', 'order' => 'rand', 'meta_key' => '_wmw_mbe_date', 'meta_key' => '_wmw_mbe_sticky', 'meta_query' => array( 'relation' => 'AND', 'key' => '_wmw_mbe_sticky', 'value' => 'sticky', 'compare' => '=' ), array( 'key' => '_wmw_mbe_date', 'value' => date("Y-m-d"), 'compare' => '>' ), 'type' => 'DATE', 'category__in' => Array ( 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ), ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); //ad ids to array to filter out in next query $post_ids[] = get_the_ID(); //get the styling wmw_results_layout(); endwhile;
So it’s about the meta_query sticky and the date-part. With the code above the date is not taken into account. If I switch the date-part above the sticky-part, the date filter is correct, but the sticky part is ignored. And v.v.
What am I doing wrong here?
Thanks for any help!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘only first part of meta_query works’ is closed to new replies.