Dynamically tax_query

Just needs a little array manipulation.

$def = array(
    'taxonomy' => 'cities',
    'field' => 'slug',
    'operator' => 'NOT IN'
);

$cities = array(
    'boston',
    'chicago'
);

$args = array('relation' => 'OR');

foreach ($cities as $c) {
     $args[] = wp_parse_args(array('terms'=>$c),$def);
}
print_r($args); 

The $cities array you need to build from your $_POST or $_GET form data, or just create the $args array as you loop through the form data in the first place.

Leave a Comment

tech