Reputation: 7481
I'm trying to figure out how to get the following code to work as one wp_query . i'm trying to filter the loop on the meta values and the taxonomy values:
Both of these sections work independently but i'm looking to tie these into one query..?
I have tried various combinations but am getting no where....any ideas of the best approach to this issue...?
$args = array(
array(
'post_type' => 'job_listing',
'meta_key' => 'geo_short_address',
'meta_value' => $area
),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'job_type',
'field' => 'term_id',
'terms' => $jobtype
),
array(
'taxonomy' => 'job_cat',
'field' => 'slug',
'terms' => $jobcat
)
)
);
Upvotes: 0
Views: 2057
Reputation: 11971
It looks as if your argument array is one level too deep. Try this:
$args = array(
'post_type' => 'job_listing',
'meta_key' => 'geo_short_address',
'meta_value' => $area,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'job_type',
'field' => 'term_id',
'terms' => $jobtype
),
array(
'taxonomy' => 'job_cat',
'field' => 'slug',
'terms' => $jobcat
)
)
);
If that doesn't work, try this:
$args = array(
'post_type' => 'job_listing',
'meta_key' => 'geo_short_address',
'meta_query' => array(
array(
'key' => 'geo_short_address',
'value' => $area
)
),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'job_type',
'field' => 'term_id',
'terms' => $jobtype
),
array(
'taxonomy' => 'job_cat',
'field' => 'slug',
'terms' => $jobcat
)
)
);
Upvotes: 1