1

我使用以下代码在我的网站上使用默认的 Woocommerce 搜索栏 (get_searchform):

<form role="search" method="get" class="search-form">

  <div class="postcode-search col-lg-4 col-lg-offset-4">

    <input type='textbox' name="s" class="form-control form-inline" style="display: inline;" id="item-search" value="<?php the_search_query();?>" placeholder="Enter your postcode"/>
    <span class="input-group-btn">
      <button class="item-search-btn"><span class="">find stores</span></button>
    </span>

    <?php
      if ( function_exists( 'woocommerce_product_search' ) ) {
        echo woocommerce_product_search( array( 'limit' => 40 ) );
      }
    ?>

  </div>

</form>

它成功显示了我所有 Woocommerce 产品的结果,但我希望它仅用于用户搜索产品类别,因此只显示父产品类别而不是产品。有谁知道我可以如何更改上面的代码来实现这一点?非常欢迎所有建议,并提前感谢您!

4

0 回答 0