查询多个分类组 slugs [英] Query multiple taxonomies group slugs

查看:32
本文介绍了查询多个分类组 slugs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于搜索查询的复选框功能.我的问题是搜索时创建的网址.

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

当我检查了多个 taxonomy_names 时,我只会得到搜索结果中的最后一个.

我需要像这样重写我的网址:

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

有没有一种简单的方法可以通过重写来更改我的网址?我尝试了一点 str_replace/preg_replace ,但没有运气.

解决方案

将输入字段的名称更改为 ct_event_type[],您将获得检查值作为数组.

<小时>

HTML 部分应如下所示:

<label for="ct_<?php echo $name; ?>">//for 应该和 checkbox id 一样<输入id="ct_"name="ct_"类型=复选框"style="margin-right:5px; margin-left:5px"value="<?php echo $t->slug; ?>"/>//<-- 关闭输入<?php echo $t->name;?>

注意label的使用.

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.

解决方案

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.

这篇关于查询多个分类组 slugs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆