I'm trying to use WP_Query to create a query that contains a meta_query element and a tax_query element. More critically, I don't want to find results that satisfy both conditions (and AND clause), I want to find results that satisfy one or the other of them (OR clause).
$loop = new WP_Query( array( 'post_type' => 'tickets', 'paged' => $paged, 'order' => $order, 'orderby' => $orderby, 'meta_query' => array( array( 'key' => 'tps_email', // Use 'key' for author 'value' => 'web@data.com', // Replace with the author ID you want to query 'compare' => 'LIKE', // Use '=' to match the author ID ), ), 'tax_query' => array( array( 'taxonomy' => 'topic', // Replace with your custom taxonomy name 'field' => 'slug', // You can use 'id', 'slug', or 'name' depending on how you want to identify the term 'terms' => 'housekeeping', // Replace with the slug of the specific term you want to query ), ), ) );
I accept this output
Here's how to set up the "OR" relationship between meta_query and tax_query: