I have inherited some code in this project. This search works. I can click on each individual taxonomy and see the results displayed on my page. However, I would like this to extend the search rather than just perform a new search i.e. I am trying to find an event in a region and the category of event and the age group. ?region=102&category=8&agegroup=74

$taxonomy_query = array();
if( isset( $_GET['region'] ) && $_GET['region'] ){
$taxonomy_region_query = array( 'taxonomy' => 'region', 'field' => 'id', 'terms' => $_GET['region'] );
$taxonomy_query[] = $taxonomy_region_query;
if( isset( $_GET['category'] ) && $_GET['category'] ){
$taxonomy_cat_query = array( 'taxonomy' => 'event_category', 'field' => 'id', 'terms' => $_GET['category'] );
$taxonomy_query[] = $taxonomy_cat_query;
if( isset( $_GET['age_groups'] ) && $_GET['age_groups'] ){
$taxonomy_age_query = array( 'taxonomy' => 'age_groups', 'field' => 'id', 'terms' => $_GET['age_groups']);
$taxonomy_query[] = $taxonomy_age_query;
if( $taxonomy_region_query & $taxonomy_cat_query & $taxonomy_age_query ){
$taxonomy_query['relation'] = 'AND';
$args = array(
        'post_type'      => array("event"),
        'post_status'    => "publish",
        'meta_key'       => "sc_event_date",
        'orderby'        => "sc_event_date",
        'meta_query'     => $search_query,
        'tax_query'      => $taxonomy_query,
        'order'              => "ASC",
        'posts_per_page' => 5,
$event_query = new WP_Query($args);`


Right, I've changed the way I perform the search, I'm now using radio buttons.

<?php foreach( $regions as $region ) : ?>
<label><input type="radio" name="?region=<?php echo $region->slug;?>" /><span><?php echo $region->name;?></span></input></label><br />
<?php endforeach;?>

I have one for region, category and agegroup. I have a new problem. I have successfully enabled the search to add on each new term, but my search query now looks like this:


The taxonomy query won't recognise this format, it will only show me the results if they appear in this format in the url:


How do I enable my search to output the same format as the taxomony query search? As far as I gather its the %3F, %3F and =on that are causing the problem. So frustrated. I'm almost there.

1 Answer 1


Ok, the problem was with my radio buttons.

<?php foreach( $regions as $region ) : ?>
<label><input type="radio" name="region" value="<?php echo $region->slug;?>" /><span><?php echo $region->name;?></span></input></label><br />
 <?php endforeach;?>

I have solved this problem by giving the radio buttons a name and value and not using any symbols in that name or value. It really was that simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.