• Resolved clk87

    (@clk87)


    Hi there,

    Is there a way to change the location of the search results? Ideally, I’d like them to display inside of a div below the search input field.

    Thanks in advance.

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

    (@msaari)

    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;
    } );
    Thread Starter clk87

    (@clk87)

    Thank you very much Mikko,

    I really appreciate the help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Location of results’ is closed to new replies.