Wordpress / Woo如何在类别中搜索?

时间:2015-11-19 13:16:58

标签: php wordpress woocommerce

在Wordpress / WooCommerce中我想按类别进行搜索,但不知怎的,我无法让它工作。 正常的搜索工作并给我这个网址http://localhost:8888/rwdr/search/[searchkeyword] 在类别中搜索时,网址的外观如何?

<form role="search" method="get" id="searchform2" action="" class="">
    <ul class="radio-ul">
      <li>
        <label for="typBA" class="typ typBA "></label>
        <input name="category" id="typBA" value="BA" type="radio">
      </li>
      <li>
        <label for="typBAX7" class="typ typBAX7 "></label>
        <input name="category" id="typBAX7" value="BAX7" type="radio">
      </li>
      <li>
        <label for="typBASL" class="typ typBASL "></label>
        <input name="category" id="typBASL" value="BASL" type="radio">
      </li>
    </ul>

    <label for="InputBox">Input Box</label>
    <input type="text" value="" id="first" name="s" />
    <input type="hidden" value="" name="x" /> </form>

我真的很感激任何帮助!

2 个答案:

答案 0 :(得分:1)

在WordPress中,我使用名为“搜索所有内容”的插件,您可以在其中设置是否要在搜索结果中添加类别,标签和许多其他选项。它非常易于使用,对我来说效果很好。

答案 1 :(得分:1)

您可以在网址

中使用标准查询进行搜索

yoursite.com/?post_type=product&taxonomy=product_cat&term=your_category_slug&s=a

要获取网址,您可以构建一个这样的表单,

<form method="get" action="" role="search">
    <input type="hidden" name="post_type" value="product">
    <input type="hidden" name="taxonomy" value="product_cat">
    <input type="hidden" name="term" value="your_category_slug">
    <input type="search" name="s" value="">
    <input type="submit" value="Search">
</form>