Query multiple taxonomies group slugs

你说的曾经没有我的故事 提交于 2020-01-06 18:10:55

问题


I have a checkbox function that I'm using for my search query. My problem is the url created when I search.

?ct_zipcode=&ct_event_type=birthday&ct_event_type=photovideo-shoot&Venue-search=true

When I have multiple taxonomy_names checked I only get the last slug in my search results.

I need my url to be rewritten like:

?ct_zipcode=&ct_event_type=birthday%2Cphotovideo-shoot&Venue-search=true 

Is there an easy way to change my url with rewrite? I've tried a little str_replace / preg_replace with no luck.


回答1:


Change the name of the input field to ct_event_type[] and you'll get the checked values as an array.


The HTML part should look like this:

<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>

Note the use of label.



来源:https://stackoverflow.com/questions/15071332/query-multiple-taxonomies-group-slugs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!