• Resolved annettepixie

    (@annettepixie)


    Hi,

    I have this working on the default settings but I’m trying to replace the results div as I need to position the search form.

    I’ve tried to use the wp get_search_form filter to provide the new div id and data-rlvparentel attribute value.

    add_filter( 'get_search_form', 'prepare_search_form' );
    
    function prepare_search_form( $form ){
    
    $form = '
    <form role="search" method="get" class="search-form" action="/">
    	<label>
    		<span class="screen-reader-text">Search for:</span>
    		<input type="search" class="search-field" placeholder="Search …" name="s" data-rlvlive="true" data-rlvparentel="#ep-rlvlive" data-rlvconfig="default">
    	</label>
    	<input type="submit" class="search-submit" value="Search">
        	<div id="ep-rlvlive"></div>
    </form>';
    
    return $form;
    
    }

    My new div is getting added but is ignored as the data-rlvparentel is being reset to the default and the default results div is also being rendered.

    <form role="search" method="get" class="search-form" action="/">
    	<label>
    		<span class="screen-reader-text">Search for:</span>
    		<input type="search" class="search-field" placeholder="Search …" name="s" data-rlvlive="true" data-rlvparentel="#rlvlive_1" data-rlvconfig="default" autocomplete="off" aria-owns="relevanssi_live_search_results_624c1e0be9b67" aria-autocomplete="both" aria-label="When autocomplete results are available use up and down arrows to review and enter to go to the desired page. Touch device users, explore by touch or with swipe gestures.">
    	</label>
    	<input type="submit" class="search-submit" value="Search">
    	<div id="ep-rlvlive"></div>
    	<div id="rlvlive_1"></div>
    </form>

    FYI I’m using Oxygen Builder which disables themes.

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

    (@msaari)

    Move your filter later in the hook, it’s probably now running before the default hook in Live Ajax Search:

    add_filter( 'get_search_form', 'prepare_search_form', 11 );

    Thread Starter annettepixie

    (@annettepixie)

    Thank you so much for getting back so quickly!

    I tried setting the priorty to 11 and also 99 but actually turns out I should have also used the relevanssi_live_search_add_result_div filter and returned false. Now works even with priorty of 10.

    Only issue is the positioning is being set on the child div class relevanssi-live-search-results, so I’m back to square one. However, I see from script.js that positioning isn’t set if the input field is hidden and as I want it initially hidden, hopefully that will sort out my issue.

    Plugin Author Mikko Saari

    (@msaari)

    I’ll mark this thread resolved; if further problems crop up, feel free to start a new thread.

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