Tagged: ajax search, SearchWP
-
AuthorPosts
-
November 2, 2020 at 4:35 am #1257498
Hi Support,
thanks for the great theme and the nice documentation.
We use the Code from https://kriesi.at/documentation/enfold/search/ to get SearchWP to work, but the ajax search doesn´t work.
Please look at the private Content and the Temporary login Link.
Thanks for your help!
Tobias
November 5, 2020 at 1:39 am #1258493Hey Tobias,
Thank you for the inquiry.
Which snippet did you add in the functions.php file? You might have added the snippet for Polylang instead of the code for the SearchWP plugin.
// https://kriesi.at/documentation/enfold/search/#use-searchwp-instead-of-the-standard-search
Best regards,
IsmaelNovember 5, 2020 at 2:13 am #1258494Hi Ismael,
thanks for your answer!
No it´s the snippet for SearchWP plugin. Please have a look at functions.php
Best regards,
Tobias- This reply was modified 4 years, 1 month ago by Tobias.
November 9, 2020 at 2:40 am #1259151Hi,
Thank you for the update.
We adjusted the searchwp function for the AJAX search a bit and it is now working as it should.
// **********************************************************************// // Search WP integration */ // **********************************************************************// add_filter( 'avf_ajax_search_function', 'avia_init_searchwp', 10, 4 ); function avia_init_searchwp( $function_name, $search_query, $search_parameters, $defaults ) { $function_name = class_exists( 'SearchWP' ) ? 'avia_searchwp_search' : $function_name; return $function_name; } function avia_searchwp_search( $search_query, $search_parameters, $defaults ) { $searchwp = SearchWP::instance(); $engine_name = 'default'; // you can swap in your Supplemental Search Engine name $search_string = isset( $search_query['s'] ) ? sanitize_text_field( urldecode( $search_query['s'] ) ) : ''; // limit the results to 5 function avia_searchwp_search_num_results() { return 5; } add_filter( 'searchwp_posts_per_page', 'avia_searchwp_search_num_results' ); $posts = $searchwp->search( $engine_name, $search_string ); return $posts; }
Best regards,
IsmaelNovember 9, 2020 at 3:38 am #1259157Hey Ismael,
thank you very much for your help. It works well!
Best regards,
TobiasNovember 9, 2020 at 7:11 pm #1259344Hi Tobias,
Glad we could help :)
If you need further assistance please let us know.
Best regards,
VictoriaJanuary 11, 2021 at 5:55 am #1271483Hi. I recently installed SearchWP on my Enfold theme site and used the code above in my functions.php file, but the ajax search isn’t working. It’s creating the following error: admin-ajax.php 500 (Internal Server Error)
Any suggestions?
January 12, 2021 at 4:36 am #1271724Hi rainporch,
Please open a new thread and include WordPress admin login details in private so that we can have a closer look at your site.
Best regards,
RikardMarch 19, 2021 at 9:29 pm #1289271Hi there! This snippet should serve you well as it works with v3 and v4: https://kriesi.at/support/topic/ajax-live-search-and-searchwp/
March 23, 2021 at 7:45 am #1289780 -
AuthorPosts
- You must be logged in to reply to this topic.