Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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

    #1258493

    Hey 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,
    Ismael

    #1258494

    Hi 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 ago by Tobias.
    #1259151

    Hi,

    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,
    Ismael

    #1259157

    Hey Ismael,

    thank you very much for your help. It works well!

    Best regards,
    Tobias

    #1259344

    Hi Tobias,

    Glad we could help :)

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1271483

    Hi. 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?

    #1271724

    Hi 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,
    Rikard

    #1289271

    Hi there! This snippet should serve you well as it works with v3 and v4: https://kriesi.at/support/topic/ajax-live-search-and-searchwp/

    #1289780

    Hi,

    Thanks for sharing, and for helping out @SearchWP :-)

    Best regards,
    Rikard

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.