This code enables you to add a expanding search form in the Navigation menu of any WordPress theme. The code is tested in the Genesis Sample child theme however it will also work in any other WordPress theme as it uses WordPress hook and not a theme specific hook.
Here’s the expanding search box in action:
The code uses PHP to add the search form to the nav menu and CSS for the effects, No jQuery used.
- Add the PHP to the end of your child themes functions file.
- Add the CSS to the end of your child themes style.css file before the start of your CSS for Media Queries.
Non Genesis Theme Usage
Simply swap out the
.genesis-nav-menu class in the CSS with the main class for your themes nav menu.
Here’s the code for logged in members: