Forums Forums Search & Filter Pro How to integrate the search field of the theme template

Tagged: ,

Viewing 10 posts - 11 through 20 (of 20 total)
  • Trevor
    #197821
    This reply has been marked as private.
    Anonymous
    #197830
    This reply has been marked as private.
    Trevor
    #197846
    This reply has been marked as private.
    Anonymous
    #197868
    This reply has been marked as private.
    Anonymous
    #197874
    This reply has been marked as private.
    Trevor
    #197922

    Yes, I have done this now.

    In the main theme is a file called searchform.php

    Copy this file to the child theme folder. If you edit the file, you will see it has this content:

    <form method="get" id="searchform" action="<?php echo esc_url(home_url('/')); ?>/">
      <div class="input-group">
        <input type="text" class="form-control" name="s" id="s" value="" placeholder="<?php esc_html_e('Search Posts...','vestige'); ?>" />
        <span class="input-group-btn">
          <button type ="submit" name ="submit" class="btn btn-primary"><i class="fa fa-search fa-lg"></i></button>
        </span>
      </div>
    </form>

    If you read this post:

    https://support.searchandfilter.com/forums/topic/keep-the-search-request/#post-137639

    You will see what needs to be changed.

    Anonymous
    #197996

    Hi Trevor, I understood but it is not working. In my theme the file that has to be modified is theme functions.php under the framework folder. If I modify the name from s to _sf_s the search doesn’t start or starts and land in the home page without results. To succeed I have to manually write the URL like this: home url/?sfid=5717&_sf_s=name_to_be_searched (where 5717 is the code of the S&F pro) and I land to the search page. If I follow your instruction I get
    home_url/?_sf_s=name_to_be_searched but I stay on the home page. To move on the search page I have to have home_url/?_sf_s=name_to_be_searched or home url/?sfid=5717&_sf_s=name_to_be_searched
    Any suggestion? The problem is that I cannot add to the base url the question mark (?)…
    Thank you

    Trevor
    #198056

    The only other way I can think of is to make a basic text search form in our plugin, set to Custom Display mode, and replace the theme search with ours. The only problem with this approach is that it requires an actual results page.

    Alternatively, you could approach the theme author and ask them how it can be modified to do as I suggested.

    Anonymous
    #198088

    At the end of the day I succeeded. I had to modify the function.php file of my theme with the following code (where 5717 is the code of the S&F PRO created:

    function fb_change_search_url_rewrite() {
    	if ( is_search() && ! empty( $_GET['s'] ) ) {
    		wp_redirect( home_url( "?sfid=5717&_sf_s=" ) . urlencode( get_query_var( 's' ) ) );
    		exit();
    	}	
    }
    add_action( 'template_redirect', 'fb_change_search_url_rewrite' );

    Thank you

    Trevor
    #198090

    Great to hear you got there. I will close this thread for now.

Viewing 10 posts - 11 through 20 (of 20 total)