Forums › Forums › Search & Filter Pro › replace standard native search header WooCommerce
- This topic has 3 replies, 2 voices, and was last updated 3 years, 11 months ago by Trevor.
-
Anonymous(Private) December 12, 2020 at 6:58 pm #269667
Hi, I installed the plugin and it seems it’s working fine used in a widget. I have also to replace the standard search bar in the header that comes with the theme, how can I achieve this? I have WooCommerce installed and need to search only products. Thank you!
Trevor(Private) December 14, 2020 at 11:16 am #269697The easiest thing to to is to use a WordPress re-write. Assuming that you have our search form on the shop page, named ‘shop’, something like this in the child theme functions.php file:
function sandf_change_search_url_rewrite() { if ( is_search() && ! empty( $_GET['s'] ) ) { wp_redirect( home_url( "shop/?_sf_s=" ) . urlencode( get_query_var( 's' ) ) ); exit(); } } add_action( 'template_redirect', 'sandf_change_search_url_rewrite' );
You would need to change the word shop if needed, and there might need to be other changes needed, depending on how your header search works. Note, the Search & Filter form on the results page must have a Text search field to receive the search string. You would not need/want to have the post type in the parameters, as this is specified in our form settings instead, so you should remove that from the theme code/template you already use.
-
AuthorPosts