2014-10-10 2 views
2

아래 코드를 사용하고 있지만 부모 카테고리에서만 제품을 검색하는 두 가지 별도 검색 양식을 추가하는 방법을 모르겠습니다. 어느 product_parent_cat_floral 또는woocommerce 검색 본문 카테고리에만 적용되는 상위 카테고리 제품

  <?php 
       $classes = get_body_class(); 
       if (in_array('product_parent_cat_rentals',$classes)) { 
      ?> 

       //rentals search form would go here 

      <?php } else { ?> 

       //flowers search form would go here 

      <?php } ?> 

product_parent_cat_rentals은 어떻게 든 그것은 단지 appropiate 부모 클래스 내에서 제품을 검색하기 위해이 검색 양식을 편집 할 수 있습니까?

<form role="search" method="get" id="searchform" action="http://botanicaevents.com/rentals/"> 
     <div> 
      <label class="screen-reader-text" for="s">Search for:</label> 
      <input type="text" value="" name="s" id="s" placeholder="Search for products" /> 
      <input type="submit" id="searchsubmit" value="Search" /> 
      <input type="hidden" name="post_type" value="product" /> 
     </div> 
    </form> 

답변

1

난 당신이 간단하게 사용할 수있을 것 같아요 :

<input type="hidden" name="product_cat" value="rentals" /> 

그래서 당신의 검색 쿼리가됩니다

:

?s=some+search+string&post_type=product&product_cat=rentals 

가 추가로 rentals 제품 카테고리 내에서 검색을 제한 할 수 있습니다.

관련 문제