Forums Forums Search & Filter Pro Using default WP search bar to show S&F results page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #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
    #243811

    In 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.

    Anonymous
    #243967

    Thanks a lot – worked great!

    Regards

    Trevor
    #243969

    Thanks for letting me know. I will close this thread for now.

Viewing 4 posts - 1 through 4 (of 4 total)