To understand how to do it you first need to know how the url query works or more specifically what query vars you need, so:
'post_type'
– to filter by post
types.'area'
– to filter by area
taxonomy.'university'
– to filter by
university taxonomy.
so your url would look like:
// http://www.domain.com/?post_type=properties&area=area_term&university=university_term
Now that we know we create the form with the needed fields:
function display_area_university_filter_form(){
?>
<form method="post" action="">
<p><label for="area_t">Area: </label> <select name="area_t"><option value="">Select Area:</option>
<?php
$area_terms = get_categories('taxonomy=area');
if (isset($_POST['area_t'])){
foreach ($area_terms as $term) {
$option = '<option value="'.$term->slug.'"';
if ($_POST['area_t'] == $term->slug){
$option.= ' selected="selected"';
}
$option .= '>'.$term->name;
$option .= '</option>';
echo $option;
}
}else{
foreach ($area_terms as $term) {
$option = '<option value="'.$term->slug.'"';
$option .= '>'.$term->name;
$option .= '</option>';
echo $option;
}
}
?>
</select>
</p>
<p><label for="area_t">University: </label> <select name="area_t"><option value="">Select University:</option>
<?php
$uni_terms = get_categories('taxonomy=university');
if (isset($_POST['univer'])){
foreach ($uni_terms as $term) {
$option = '<option value="'.$term->slug.'"';
if ($_POST['univer'] == $term->slug){
$option.= ' selected="selected"';
}
$option .= '>'.$term->name;
$option .= '</option>';
echo $option;
}
}else{
foreach ($uni_terms as $term) {
$option = '<option value="'.$term->slug.'"';
$option .= '>'.$term->name;
$option .= '</option>';
echo $option;
}
}
?>
</select>
</p>
<input type="hidden" name="custom_filter" value="area_uni">
<p><input type="submit" name="submit" value="submit"></p>
</form>
<?php }
then all that is left is just processing it:
if (isset($_POST['submit']) && isset($_POST['custom_filter']) && $_POST['custom_filter'] == "area_uni"){
$url = get_bloginfo('url');
$area = $uni = '';
if (isset($_POST['area_t'])){
$area="&area=".$_POST['area_t'];
}
if (isset($_POST['univer'])){
$uni = '&university='.$_POST['univer'];
}
$url .= '/?post_type=properties'.$area.$uni;
wp_redirect( $url );
exit();
}