Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Redirection of empty search queries

Viewing 4 posts - 1 through 4 (of 4 total)
  • Lennart Schuett
    #249557

    Hi,

    I redirect search queries as described here: https://support.searchandfilter.com/forums/topic/using-default-wp-search-bar-to-show-sf-results-page/#post-243811 It works fine, but I discovered today that redirection doesn’t work when an empty search query is entered. Is there any way to change that?

    Thanks

    Trevor Moderator
    #249558

    MMM. Maybe:

    function sandf_change_search_url_rewrite() {
    	$search_string = "";
    	if ( is_search() ) {
    		if (! empty( $_GET['s'] ) ) {
    			$search_string = urlencode( get_query_var( 's' ) );
    		}
    		wp_redirect( home_url( "search-results/?_sf_s=" ) . $search_string );
    		exit();
    	}	
    }
    add_action( 'template_redirect', 'sandf_change_search_url_rewrite' );

    That might work.

    Lennart Schuett
    #249567

    Works fine. Thank you.

    Trevor Moderator
    #249569

    Thanks for getting back to me. I will close this thread for now.

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

The topic ‘Redirection of empty search queries’ is closed to new replies.