Skip to content
Advertisement

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(); ?>

Advertisement

Answer

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()
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement