WordPress menus display as unordered lists by default. You might want to display them as a select menu though. Below is an example of creating a menu ‘walker’ that will render it as a select menu. When you are displaying your menu using wp_nav_menu(), include 'walker' => new Walker_Nav_Menu_Dropdown() to tell WordPress to use this type of formatting rather than the default.
| <?php | |
| // Nav Menu Dropdown Class | |
| include_once( CHILD_DIR . '/lib/classes/nav-menu-dropdown.php' ); | |
| /** | |
| * Mobile Menu | |
| * | |
| */ | |
| function be_mobile_menu() { | |
| wp_nav_menu( array( | |
| 'theme_location' => 'mobile', | |
| 'walker' => new Walker_Nav_Menu_Dropdown(), | |
| 'items_wrap' => '<div class="mobile-menu"><form><select onchange="if (this.value) window.location.href=this.value">%3$s</select></form></div>', | |
| ) ); | |
| } | |
| add_action( 'genesis_before_header', 'be_mobile_menu' ); |