I have created a custom post type with custom fields and I need to filter them based on several meta data values.
$args = array( 'post_type' => 'match_report', 'post_status' => 'publish', 'meta_key' => 'report_type', 'meta_value' => 'cup', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'report_home-select', 'value' => $team_id, 'compare' => '=', ), array( 'key' => 'report_away-select', 'value' => $team_id, 'compare' => '=' ) ) ); $reports = new WP_Query($args);
Basically I want to create a meta query that has a relation of OR and AND. So in English I want the all the match reports with the
report_type 'cup' that have either the
report_home-select key with the value of a specific team_id OR the
report_away-select key with the same value. I hope that makes sense. In essence I want a double relation.