I’m working on a wp project with responsive theme.
I have single level nav menu at the top of the site, that I want to change to a Select Option tag for mobile browsers (small screens) with options for the nav items which is much easier to select in mobile site. So the UL LI menu will be replaced with a Selection- Option tag for mobile.
However, I’m unable to figure out how to change wp menu to a select option dropdown.
Here’s what I’ve put together from different articles/themes:
files to modify:
functions.php
header.php
style.css
js (create folder “js” in theme root directory)
The Javascript:
save as custom.js and place in the js folder of the theme directory.
The functions.php file:
Open your themes functions.php file and locate the code that enqueues any existing styles or scripts and add this to the init:
. add this line to the If your theme doesn’t enqueue add this to your functions.php file:
The header.php file:
Replace/add current wp-nav css id or class as follows:
<nav>
...Your themes navigation code here
</nav>
The CSS:
Adjust the css style to your liking.
If your menu includes children the following code works well (in place of the above javascript)
simply use this plugin. Its better than just a dropdown menu
https://wordpress.org/plugins/wp-responsive-menu/