Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1032810

    Hello,

    Yes I have checked all those previous threads and those are very conflicted, someone said worked and someone said not worked.

    So, I have created this post to get a final CSS code which will allow a search bar for mobile version.

    Thanks

    #1034093

    Hey Sovik,

    I don’t see the search bar at all. Do you have it added somewhere?

    Best regards,
    Victoria

    #1034110
    This reply has been marked as private.
    #1035017

    Hi,

    Thanks for the update.

    Add this code on the functions.php file to render the search icon inside the mobile menu:

    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
    }
    

    After that, add this css code on the Quick CSS field:

    #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;
    }

    Related thread: https://kriesi.at/support/topic/search-field-on-mobiles-has-been-disappeared-after-last-enfolds-update/#post-925174

    Best regards,
    Ismael

    #1042619
    This reply has been marked as private.
    #1043080

    Hi,

    Add this filter to exclude other posts types from the ajax search.

    add_filter('avf_ajax_search_query', 'avf_ajax_search_query_mod', 10, 1);
    function avf_ajax_search_query_mod( $search_parameters )
    {
    	$footer = avia_get_option( 'footer_page', 0 );
    	$defaults = array('numberposts' => 5, 'post_type' => array( 'product' ), 'post__not_in' => array($footer), 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false);
    	$_REQUEST['s'] = apply_filters( 'get_search_query', $_REQUEST['s']);
    	$search_parameters = array_merge( $defaults, $_REQUEST );
    	return $search_parameters;
    }

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.