Overriding the product search box (widget)

You are here:

The product search box widget loads the search box using the template function:


For more info, see: Function get_product_search_form.

It then looks for the product search form in the file ‘product-searchform.php’ or uses its default markup. You can override the default WooCommerce template product-searchform.php by customizing the markup.

For reference, the default markup is:

  <form role=”searchmethod=”getclass=”woocommerce-product-searchaction=”<?php echo esc_url( home_url( ‘/’ ) ); ?>>
  <label class=”screen-reader-textfor=”s><?php _e( ‘Search for:’, ‘woocommerce’ ); ?></label>
  <input type=”searchclass=”search-fieldplaceholder=”<?php echo esc_attr_x( ‘Search Products&hellip;’, ‘placeholder’, ‘woocommerce’ ); ?>value=”<?php echo get_search_query(); ?>name=”stitle=”<?php echo esc_attr_x( ‘Search for:’, ‘label’, ‘woocommerce’ ); ?>” />
  <input type=”submitvalue=”<?php echo esc_attr_x( ‘Search’, ‘submit button’, ‘woocommerce’ ); ?>” />
  <input type=”hiddenname=”post_typevalue=”product” />
Was this article helpful?
Dislike 0
Views: 11