我正在一个网站上工作,我需要在一个分类中查询多个术语。目前,我有以下适用于下拉菜单的内容。
function ct_search_form_select_quick($name, $taxonomy_name = null) {
global $search_values;
if (!$taxonomy_name) {
$taxonomy_name = $name;
}
?>
<select id="ct_<?php echo $name; ?>" name="ct_<?php echo $name; ?>">
<option value="0"><?php _e('Any', 'theme_textdomain'); ?></option>
<?php foreach( get_terms($taxonomy_name, 'hide_empty=0') as $t ) : ?>
<?php if ($search_values[$name] == $t->slug) { $selected = 'selected="selected" '; } else { $selected = ''; } ?>
<option <?php echo $selected; ?>value="<?php echo $t->slug; ?>"><?php echo $t->name; ?></option>
<?php endforeach; ?>
</select>
但是,我希望能够在一个分类中查询多个术语。
我有以下代码,它允许我选择术语并输出第一个术语的结果,但忽略第二个术语。URL 输出为
?property_type=condo-duplex&property_type=condo-loft&ct_price_from=&ct_price_to=&ct_mls=&property-search=true&x=32&y=18,需要输出为?property_type=condo-duplex,condo-loft&ct_price_from=&ct_price_to=&ct_mls=&property-search=真&x=32&y=18
function ct_search_form_select($name, $taxonomy_name = null) {
global $search_values;
if (!$taxonomy_name) {
$taxonomy_name = $name;
}
?>
<input type="checkbox" value="0" name="ct_<?php echo $name; ?>"><?php _e('Any', 'theme_textdomain'); ?>
<?php foreach( get_terms($taxonomy_name, 'hide_empty=0') as $t ) : ?>-->
<?php if ($search_values[$name] == $t->slug) { $selected = 'selected="selected" '; } else { $selected = ''; } ?>
<input type="checkbox" name="<?php echo $name; ?>" value="<?php echo $t->slug; ?>"><?php echo $t->name; ?>
<?php endforeach; ?>