I've not been able to find my way using the existing answers; hence decided to post a new question anyway. What I want to achieve has probably been done 20,000 times; but I might just be an idiot. Anyway -
What I have: 1. Custom Post Type: 'job' 2. Each 'job' has: custom_filed_1: location , custom_field_2: company 3. It also has: custom_taxonomy_1: skills, custom_taxonomy_2: disciplines
For the life of me, I can't figure out how to write WP_QUERY that will help me retrieve posts that have: custom_field_1 AND custom_taxonomy_1 AND custom_taxonomy_2.
Like searching for jobs available in "New York" AND Skills "PHP + WordPress" AND available for "Computer Science Engineers".
My main confusion is how do I have 'AND' / 'OR' relationship between 'meta_query' and 'tax_query' arguments of WP_Query.
Would really appreciate your help. Thanks!
Here's my sample code:
$args = array(
'post_type' => array('job'),
'post_status' => array('publish'),
'posts_per_page' => '5',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'location',
'value' => $search_location,
'compare' => 'LIKE',
),
array(
'key' => 'company',
'value' => $search_company,
'compare' => 'LIKE',
),
),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'skills',
'field' => 'slug',
'terms' => $search_skills,
'operator' => 'IN'
),
array(
'taxonomy' => 'disciplines',
'field' => 'slug',
'terms' => $search_disciplines,
'operator' => 'IN'
),
);