Turn off Live Search
This support request was posted in Flatbase by nyceco
- nyceco October 29, 2014 at 7:59 pm
Hi – I’d like to turn off the Live Search functionality since it searches on every letter entered. I keep track of my users’ search terms, so after searching for “apple,” my report counts the following as search terms:
ap
app
appl
appleI still want to use the main search box on the front page. I just need to turn off the automatic searching. Thanks!
Juanfra Aldasoro October 29, 2014 at 10:57 pmHi,
Thanks for writing and hoping that you are doing well today.
Well, there’s an option within the theme options in order to disable the live search. I understand that you want to maintain the search form but avoid having the live search functionality. Unfortunately that can’t be done through the theme options and the only way to achieve that would be customizing the javascript file which triggers the live search functionality. It is not the best way to go, but it should work. The file is in /includes/js/general.js
Best,
Juannyceco October 30, 2014 at 1:51 pmHi Juan,
Thanks for the information. In the general.js file I see a section that talks about the Livesearch label, but customizing that only affects whether the pre-filled text, “Have a question? Ask or enter a search term,” changes as the user enters text. Upon entering text, the search box still does the auto-search.
I’m not a JS pro by any means, so maybe I’m missing it.
nyceco October 30, 2014 at 2:11 pmI disabled Live Search by commenting out the appropriate register and enqueue script lines in scripts.php. I hope I didn’t break anything else!
Juanfra Aldasoro October 30, 2014 at 3:12 pmHi there,
Thanks for your prompt response. Yes, you are right, you can do it that way.
Remember to comment this line as well:
add_action( 'wp_head', 'nice_livesearch_js', 10 );
That function is the one in charge of initializing the javascript library. If you only comment the enqueue functions then, that action will be trying to initialize the javascript without the library and you’ll get an error.
Best,
Juan.nyceco October 30, 2014 at 6:31 pmThanks, Juan. I commented out the add_action and it seems like everything is working okay.
This topic is marked as resolved
Only the topic author can re-open this thread.