WordPress Avada Search – how to add the live Avada Search to a Top Secondary Menu

Question

I am trying to add the Avada live search into the Top Secondary Menu. I managed to add there a normal search bar but without the Avada Live Search option.

Thanks for your help!

enter image description here

functions.php

function head_nav_search($items, $args) {
    if( !($args->theme_location == 'top_navigation') ) 
    return $items;
    return $items . '<li style="margin-top:1px;">' . get_search_form(false) . '</li>';
}
add_filter('wp_nav_menu_items', 'head_nav_search', 10, 2);

searchform.php

<form role="search" class="searchform fusion-search-form" method="get" action="<?php echo esc_url_raw( home_url( "https://wordpress.stackexchange.com/" ) ); ?>">

    <div class="fusion-search-form-content">
        <div class="fusion-search-field search-field">
            <label class="screen-reader-text" for="s"><?php esc_attr_e( 'Search for:', 'Avada' ); ?></label>
            <input  type="text" value="<?php if( is_search() ){ echo get_search_query(); } /*else { _e('Search'); }*/ ?>" name="s" class="s" placeholder="<?php esc_html_e( 'Search ...', 'Avada' ); ?>" required aria-required="true" aria-label="<?php esc_html_e( 'Search ...', 'Avada' ); ?>"/>
            
        </div>
        <div class="fusion-search-button search-button">
            <input type="submit" class="fusion-search-submit searchsubmit" value="&#xf002;" />
        </div>
    </div>
</form>

0
Zuzana 1 month 2021-08-17T10:25:47-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse