Q:

how to filter the Wordpress loop from multiple form inputs using WP_query

I'm trying to filter the loop using a series of dropdown boxes . I have everything setup ok but am stuck on the best/correct method to filter the loop on any combination of the form values.
What i have at the moment is form with 2 dropdown boxes - job_type and job_cat which posts the values via $_GET - populating the WP_query:
<?php 
if (isset($_GET['action'])){
$jobtype = $_GET['type'];
$jobcat = $_GET['cat'];
}

$args = array(
'tax_query' => array(
        'relation' => 'AND',
    array(
        'taxonomy' => 'job_type',
        'field' => 'term_id',
        'terms' => $jobtype
    ),
        array(
        'taxonomy' => 'job_cat',
        'field' => 'slug',
        'terms' => $jobcat
    )
)
);

// The Query

$the_query = new WP_Query( $args );?>
Using this method i can filter the loop on both values but I want to be able to filter on any combination. i will eventually have around 5 filter options on the form.
So the user can search just on Job Type or just on Job cat or on both.
I hope this makes sense...? thanks in advance...   

A:

Replace the 'term_id' with the 'id' if you are passing id of the job type in $jobtype variable. If you are passing slug then make it 'slug'.
Source: http://codex.wordpress.org/Class_Reference/WP_Query

