Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #581422

    Hi guys!

    On mobile the search icon dissapears in the header. I found some solutions here on the forum, but they all don’t seem to work with me :-S
    Is there a way to add a search box at the top, like all the apps and big sites have nowadays?

    grt Boris

    #582862

    Hi Boris!

    Thank you for using Enfold.

    You can add the search box inside the mobile menu. Add this in the functions.php file:

    
    add_filter( 'wp_nav_menu_items', 'avia_append_search_nav', 10, 2 );
    
    function avia_append_search_nav ( $items, $args )
    {
    
    		if ($args->theme_location == 'avia') {
    	        $search_form = get_search_form(false);
    			$items = '<li id="menu-item-searchbox">'.$search_form.'</li>' . $items;
        	}
    		return $items;
    }
    

    And this code in the Quick CSS field:

    #menu-item-searchbox form div {
    display: block !important;
    opacity: 1 !important;
    width: auto !important;
    }
    
    #menu-item-searchbox form div #s {
        width: 300px !important;
        max-width: 300px;
    }
    
    #menu-item-searchbox {
    top: 25px;
    }
    
    #top #searchsubmit, .ajax_load {
        right: 0px;
    }

    Regards,
    Ismael

    #586368

    Hey Ismael,

    Is there a certain place in the ‘functions.php file’ where I should put it or can I put it anywhere?

    grt Boris

    #586926

    Hi Boris,

    Please try it at the end to see if you have any luck with it.

    Best regards,
    Rikard

    #587513

    Hey Rikard,

    Aha ok. Is there anything after the code I should put in that file, as a final ender or so!? Or just copy paste it at the end?

    grt Boris

    #588159

    Hi,

    No it should work simply copy/pasting it, not sure what your functions.php file looks like but the only thing to look out for it to not paste it after the end php code, it there is one:

    ?>
    

    Thanks,
    Rikard

    #591035

    Hey Rikard,

    I just checked, there is no end php code!? Should there be one?

    grtz Boris

    #591373

    Hi,

    If it works without one all is good, if it doesn’t work then please try to add it to see if that works better.

    Regards,
    Rikard

    #591479

    Ah ok, thx. Well it is working ;-)

    #591493

    Hey!

    Glad you got it short out.
    let us know if we can do anything else for you.

    Cheers!
    Basilis

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘search box in header on mobile’ is closed to new replies.