wordpress - woocommerce search only parent category products based on body class -
I am using the code given below but I'm not sure how to add it to two different search forms The categories of products that only parents search in. Either Can I search this search form anyway in the Apprentice Parent class? I think you can use just: < Pre> Then your search query is created: additionally to restrict search within the product_parent_cat_floral or
product_parent_cat_rentals
& lt; Php $ classes = get_body_class (); If (in_array ('product_parent_cat_rentals', $ square)) {? & Gt; // Rent search form goes here & lt ;? Php} else {? & Gt; // flower search form goes here & lt ;? Php}? & Gt;
& lt; Form role = "search" method = "get" id = "search form" = "http://botanicaevents.com/rentals/" & gt; & Lt; Div & gt; & Lt; = "S" for label class = "screen-reader-text" & gt; Search for: & lt; / Label & gt; & Lt; Input type = "text" value = "" name = "s" id = "s" placeholder = "search for products" / & gt; & Lt; Input type = "submit" id = "searchsubmit" value = "search" /> & Lt; Input type = "hidden" name = "post_type" value = "product" /> & Lt; / Div & gt; & Lt; / Form & gt;
& lt; Input type = "hidden" name = "product_kat" value = "rent" />
? S = some + search + string & amp; Post_type = product and product_cat = rent
rental product category.
Comments
Post a Comment