tax_query is not working when i am trying to add two taxonomies (wordpress)
-
When I am trying to add two taxonomies (category and a custom taxonomy) on tax_query.The code is not working as it should. Actually I am trying to filter some packages based on categories and location(custom taxonomy) But everytime I am getting no results returned. Ideally it should be returning 2 packages.
Here is the code snippet:
elseif((($_REQUEST[‘cmbcats1’] != “”) || ($_REQUEST[‘cmbcats1’] != -1)) && (($_REQUEST[‘cmbcats’] != “”) || ($_REQUEST[‘cmbcats’] != -1))) //This will >execute if both the dropdowns contains value
$args[‘tax_query’] = array(
‘relation’ => ‘AND’,
array ( ‘taxonomy’ => ‘packagetax’,
‘terms’ => $_REQUEST[‘cmbcats’],
‘field’ => ‘term_taxonomy_id’,
‘operator’ => ‘IN’,
),
array(
‘taxonomy’ => ‘location’,
‘terms’ => $_REQUEST[‘cmbcats1’],
‘field’ => ‘term_taxonomy_id’,
‘operator’ => ‘IN’, ), );//PERFORMING LOOP…
$the_query = new WP_Query($args);
if($the_query->have_posts()):
while($the_query->have_posts()): $the_query->the_post(); >?>
- The topic ‘tax_query is not working when i am trying to add two taxonomies (wordpress)’ is closed to new replies.