• Resolved dominicht

    (@dominicht)


    Hi,

    I’m trying to override the search-results-message.php template in my theme. I created a relevanssi-live-ajax-search folder in my theme and added the template file in there but it isn’t working. It seems like the plugin’s code isn’t allowing override for this file and the issue is located in the get_ajax_messages_template() function around line 45 of the class-relevanssi-live-search-client.php file. Is it possible to update the plugin to allow overrides at the theme level for this file, just like the search result template?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    I’ll fix that in the next version. Meanwhile, you can do this:

    add_action( 'init', function() {
        global $wp_filter;
        unset( $wp_filter['wp_ajax_relevanssi_live_search_messages'] );
        unset( $wp_filter['wp_ajax_nopriv_relevanssi_live_search_messages'] );
    
        add_action( 'wp_ajax_relevanssi_live_search_messages', 'custom_get_ajax_messages_template' );
        add_action( 'wp_ajax_nopriv_relevanssi_live_search_messages', 'custom_get_ajax_messages_template' );
    }, 11 );
    
    function custom_get_ajax_messages_template() {
        ob_start();
        include __DIR__ . '/templates/search-results-messages.php';
        $content = ob_get_clean();
        wp_send_json( $content );
    }
    Plugin Author Mikko Saari

    (@msaari)

    2.2.0 is out now, so you should be able to just override the template.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Template override not working for search-results-message.php’ is closed to new replies.