wp_query with multiple fields not working
-
I have a custom content type called sportpages. It has fields called ecpt_link and ecpt_season. Link is a checkbox and season is a select box.
I have one post with link set to “on” and a season of “Fall”.
Using wp_query this works to get that one:
$args = array( 'post_type' => 'sportpages' ,'post_status' => 'publish' ,'posts_per_page' => 1000 ,'meta_key' => 'ecpt_link' ,'meta_value' => 'on' );This also worked to get that one:
$args = array( 'post_type' => 'sportpages' ,'post_status' => 'publish' ,'posts_per_page' => 1000 ,'meta_key' => 'ecpt_season' ,'meta_value' => 'Fall' );This however gets ALL posts, ignoring everything in meta_query:
$args = array( 'post_type' => 'sportpages' ,'post_status' => 'publish' ,'posts_per_page' => 1000 ,'meta_query' => array( array( 'meta_key' => 'ecpt_link' ,'meta_value' => 'on' ,'compare' => '=' ) ,array( 'meta_key' => 'ecpt_season' ,'meta_value' => 'Fall' ,'compare' => '=' ) ) );I’ve tried it without the comparison operators as well. What am I missing?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘wp_query with multiple fields not working’ is closed to new replies.