Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created April 7, 2014 16:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/10023506 to your computer and use it in GitHub Desktop.
Save billerickson/10023506 to your computer and use it in GitHub Desktop.
<?php
/**
* Primary Nav using Dropdown Walker
*
* @param array $args
* @return array
*/
function be_primary_nav_dropdown( $args ) {
if( 'primary' !== $args['theme_location'] || !class_exists( 'Walker_Nav_Menu_Dropdown' ) )
return $args;
$args['depth']= 1;
$args['walker'] = new Walker_Nav_Menu_Dropdown();
$args['items_wrap'] = '<div class="mobile-menu"><form><select onchange="if (this.value) window.location.href=this.value"><option value="">Go To&hellip;</option>%3$s</select></form></div>';
return $args;
}
add_filter( 'wp_nav_menu_args', 'be_primary_nav_dropdown' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment