I am creating a custom search system which search my custom post type recipes, in the search it searches the taxonomies terms that people have selected.
Now due to the way it can hard code all these i need to build the args by a loop of some sort.
Here a code example if what i have,
$args = array(
'post_type' => get_post_type(),
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
'no_found_rows' => true,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product_category',
'field' => 'slug',
'terms' => array($category->slug), //Supply the current product_category terms
),
array(
'taxonomy' => 'product_locations',
'field' => 'slug',
'terms' => array($current_location), //Add the product_locations term
'operator' => 'IN',
),
),
);
What i need is to add:
array(
'taxonomy' => 'product_category',
'field' => 'slug',
'terms' => array($category->slug), //Supply the current product_category terms
),
What i need is to add them programmatically when a person selects i have tried build the args array with loops and adding strings together but i can't get it to work. Does anyone have any quick way it can be done?