Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #924246

    Dear Sirs,

    In mobile menu there was a search field as you will see in attachment but after last Enfold’s update has been disappeared.

    Pls see attachment: https://prnt.sc/ioqspn

    The snippet code thas I was used for the search field on mobiles:

    in Functions.php file:

    /* Search Form on Mobile version */
    add_filter( ‘wp_nav_menu_items’, ‘avf_add_search’, 3, 2 );
    function avf_add_search( $items, $args ) {
    if ($args->theme_location == ‘avia’)
    {
    $search = ‘<li id=”menu-item-search-mobile” class=”menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-18 current_page_item menu-item-top-//level menu-item-top-level-5″>’.get_search_form(false).’‘;
    $items = $search . $items;
    }
    return $items;
    }

    I am waiting for your precious help.

    Thank You in advance.

    Best Regards,
    Nick

    #925174

    Hey nickgin,

    Thank you for using Enfold.

    Please remove the previous modification then add this code inside the functions.php file.

    add_filter( 'wp_nav_menu_items', 'avf_add_search', 9999, 2 );
    function avf_add_search( $items, $args ) {
    	if ($args->theme_location == 'avia')
    	{
    		$search = 'li id="menu-item-search-mobile" class="menu-item"></li>';
    		$items = $search . $items;
    	}
    	return $items;
    }
    
    add_action('wp_footer', 'avf_add_search_script');
    function avf_add_search_script(){
    ?>
    <script type="text/javascript">
    (function($) {
    	$('.av-burger-menu-main').on('click', function() {
    		var page   = window.location.href;
    		var mobile = $('.menu-item-search-mobile');
    		var search = '<form action="'+page+'" method="get" class=""><div><input type="submit" value="" id="searchsubmit" class="button avia-font-entypo-fontello"><input type="text" id="s" name="s" value="" placeholder="Search"></div></form>';
    
    		setTimeout(function() {
    			if(mobile.find('form').length == 1) return;
    			mobile.html(search);
    		}, 500);		
    	});
    })(jQuery);
    </script>
    <?php
    }

    And add this css code in the Quick CSS field. Don’t forget to re-save the theme options, remove browser cache and do a hard refresh before checking the page.

    #top #wrap_all #header #av-burger-menu-ul > li.av-active-burger-items.menu-item-search-mobile {
        padding: 0 30px;
        position: relative !important;
    }
    
    #top #wrap_all #header #av-burger-menu-ul > li.av-active-burger-items.menu-item-search-mobile form {
        position: relative !important;
    }

    Best regards,
    Ismael

    #925316

    Hi Ismael.

    You are a so great developer!!! Your code works as always!!!

    Thank you so much for your precious help!!

    I really appreciate your excellent support!!!

    You can close the ticket.

    Best regards,
    Nick

    #925401

    Hi Nick,

    Glad that Ismael helped you, he’s an excellent and great support:) Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Search field on mobiles has been disappeared after last Enfold's update’ is closed to new replies.