2
我正在使用下面的代碼,但不知道如何添加兩個單獨的搜索表單,僅在父類別中搜索產品。無論是product_parent_cat_floral
或product_parent_cat_rentals
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 } ?>
我可以編輯該搜索表單以某種方式使它只此時,相應的父類中搜索產品?
<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>