That’s what the Live Ajax Search should do by default, but if you want to be more specific about where the results are, that’s possible.
This code snippet can be used to override the default behaviour. It places the search results div
right after the form
element, but you can modify that, and especially if you only have one search form per page, you can place the div
anywhere you want in your templates, as long as the div
has the correct id
value.
add_filter( 'relevanssi_live_search_hijack_get_search_form', '__return_false' );
add_filter( 'get_search_form', function( $html ) {
global $form_number;
$config = apply_filters( 'relevanssi_live_search_get_search_form_config', 'default' );
if ( ! $form_number ) {
$form_number = 10;
}
$form_id = 'rlvlive_' . $form_number++;
$parentel = 'data-rlvparentel="#' . $form_id . '"';
$html = str_replace( 'name="s"', 'name="s" data-rlvlive="true" ' . $parentel . ' data-rlvconfig="' . esc_attr( $config ) . '"', $html );
$html = str_replace( '</form>', '</form><div id="' . $form_id . '"></div>', $html );
return $html;
} );