我有一个复选框函数,我使用我的搜索查询。我的问题是我搜索时创建的url。
?ct_zipcode=&ct_event_type=birthday&ct_event_type=photovideo-shoot&Venue-search=true
当我检查了多个taxonomy_name时,我只得到搜索结果中的最后一个。
我需要我的url重写为:
?ct_zipcode=&ct_event_type=birthday%2Cphotovideo-shoot&Venue-search=true
是否有一个简单的方法来改变我的url重写?我试过一点str_replace
/preg_replace
,但没有运气。
将输入字段的名称更改为ct_event_type[]
,您将获得作为数组的检查值
HTML部分应该像这样:
<div>
<label for="ct_<?php echo $name; ?>"> // for should be the same as checkbox id
<input
id="ct_<?php echo $name; ?>"
name="ct_<?php echo $name; ?>"
type="checkbox"
style="margin-right:5px; margin-left:5px"
value="<?php echo $t->slug; ?>" /> // <-- closing input
<?php echo $t->name; ?>
</label>
</div>
注意label
的使用