Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging a general wordpress search with a woocommerce product search?

I am using the following two codes to generate a wordpress search and a woo commerce product search? Is there a code to merge theme into one search bar doing both functions?

  <?php get_search_form(); ?>
  <?php get_product_search_form(); ?>
like image 220
Arthur Mamou-Mani Avatar asked Dec 11 '22 16:12

Arthur Mamou-Mani


2 Answers

get_search_from(); covers both.
get_product_search_form() is same as get_search_from() just that it restricts the wordpress search to products only.

If you see the markup of both the functions, there's only one difference. There is an additional post type value set as a product.

<input type="hidden" name="post_type" value="product" />

So,

get_search_from() >> get_product_search_form()
like image 120
Mr.Vibe Avatar answered May 19 '23 02:05

Mr.Vibe


I used the plugin Relevanssi which allows you to include custom post types (including woocommerce products) in the search results along with posts.

like image 36
cinemafunk Avatar answered May 19 '23 00:05

cinemafunk