Forums › Forums › Search & Filter Pro › Using default WP search bar to show S&F results page
- This topic has 3 replies, 2 voices, and was last updated 5 years, 9 months ago by
Trevor.
-
Anonymous(Private) May 13, 2020 at 3:28 pm #243753
Hi there,
Is it possible to use the default WordPress search bar as a search input box, but display the results on a Search & Filter Pro generated results page?
So a search URL of https://testsite.com/?s=search+term will redirect to https://testsite.com/search-results/?_sf_s=search+term – where the /search-results/ is a Page with the S&F Pro filter and results shortcodes on it.
Thanks
Trevor(Private) May 14, 2020 at 5:57 am #243811In your child theme functions.php file* you would have a function like this:
function sandf_change_search_url_rewrite() { if ( is_search() && ! empty( $_GET['s'] ) ) { wp_redirect( home_url( "search-results/?_sf_s=" ) . urlencode( get_query_var( 's' ) ) ); exit(); } } add_action( 'template_redirect', 'sandf_change_search_url_rewrite' );* Note on child theme. Normally, one should work with a child theme (it is what WordPress recommends). If you are not, then make one using the Orbisius plugin that will do it for you. Simply accept the default settings and it will make and activate it for you, then you can remove that plugin. It should not change anything about your site.
Modified files (such as the functions.php file) should always be kept in the child theme folder.
-
AuthorPosts