Tagged: header, mobile, search box
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
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
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
Hi Boris,
Please try it at the end to see if you have any luck with it.
Best regards,
Rikard
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
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
Hey Rikard,
I just checked, there is no end php code!? Should there be one?
grtz Boris
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
Ah ok, thx. Well it is working ;-)
Hey!
Glad you got it short out.
let us know if we can do anything else for you.
Cheers!
Basilis