Forums › Forums › Search & Filter Pro › How to integrate the search field of the theme template
Tagged: integration, V3
- This topic has 19 replies, 2 voices, and was last updated 5 years, 11 months ago by Trevor.
-
Trevor(Private) January 3, 2019 at 3:31 pm #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(Private) January 4, 2019 at 2:10 pm #197996Hi 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 youTrevor(Private) January 4, 2019 at 5:14 pm #198056The 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(Private) January 5, 2019 at 4:51 am #198088At 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
-
AuthorPosts