我已经找了几个小时的例子来说明如何做到这一点。我有两个简单的分类法,类型,大小。我需要创建一个自定义表单,其中有两个分类法可用作选择列表/过滤器。
请帮忙!
提前发送
<form role="search" method="get" id="searchform" action="<?php bloginfo(\'home\'); ?>">
<input type="text" value="" name="s" id="s" />
<?php
function get_terms_dropdown($taxonomies, $selectname,$args){
$myterms = get_terms($taxonomies, $args);
$selected = "selected";
$output ="<select name=\'".$selectname."\'><option selected=\'".$selected."\'>Select</option>\'";
foreach($myterms as $term){
//$term_taxonomy=$term->$taxonomies;
$term_slug=$term->slug;
$term_name =$term->name;
$output .="<option value=\'".$term_slug."\'>".$term_name."</option>";
}
$output .="</select>";
return $output;
}
$taxonomies = array(\'location\');
$taxonomies2 = array(\'function\');
$taxonomies3 = array(\'sector\');
$args = array(\'order\'=>\'ASC\',\'hide_empty\'=>false);
echo "<br />".get_terms_dropdown($taxonomies,\'location\' ,$args)."<br />";
echo get_terms_dropdown($taxonomies2,\'function\' ,$args)."<br />";
echo get_terms_dropdown($taxonomies3, \'sector\' ,$args)."<br />";
?>
<input type="submit" id="searchsubmit" value="Search" />
</form>