• I have the ajax form showing in a modal. Works fine, but I’d like to modify the results template. Problem is I’m using the Oxygen builder, which disables the theme.

    I’ve attempted to use a filter hook to point things at an alternate location, but the results are just blank now — which makes me think it’s not finding the template.

    Here’s the filter I’m using:

    add_filter( 'relevanssi_live_search_results_template', '/template-overrides/relevanssi-live-ajax-search/search-results.php' );

    Not quite sure what I’m doing wrong here.

    • This topic was modified 2 years, 3 months ago by montidesign.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mikko Saari

    (@msaari)

    I think the relative path is resolving wrong. You could always make it an absolute path to make sure it gets resolved correctly.

    Thread Starter montidesign

    (@montidesign)

    Thanks for the speedy reply!

    I used the absolute URL and I get the same result — blank.

    add_filter( 'relevanssi_live_search_results_template', 'https://domain.com/template-overrides/relevanssi-live-ajax-search/search-results.php' );

    Plugin Author Mikko Saari

    (@msaari)

    Sorry, I wasn’t clear enough. I meant the absolute path, not the absolute URL. The URL won’t work; the template path needs a file system path.

    But… Doesn’t it need to be a function call or an anonymous function?

    Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "<full-path>/search-results.php" not found or invalid function name in /wp-includes/class-wp-hook.php:309

    Plugin Author Mikko Saari

    (@msaari)

    Yes, good catch. Something like:

    add_filter( 'relevanssi_live_search_results_template', function() { return '/template-overrides/relevanssi-live-ajax-search/search-results.php'; } );

    • This reply was modified 2 years, 1 month ago by Mikko Saari.

    Like this?

    add_filter( 'relevanssi_live_search_results_template', function(){ return dirname( __file__) . "/search-results.php";} );

    Plugin Author Mikko Saari

    (@msaari)

    Yes, if that dirname() returns the correct path.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search results template override’ is closed to new replies.