Skip to content

Instantly share code, notes, and snippets.

@frekw
Last active December 14, 2015 02:09
Show Gist options
  • Save frekw/5011834 to your computer and use it in GitHub Desktop.
Save frekw/5011834 to your computer and use it in GitHub Desktop.
A Wordpress nav_menu walker for adding parent classes to dropdowns
class ParentWalker extends Walker_Nav_Menu {
function display_element ( $element, &$children, $max_depth, $depth = 0, $args, &$output ) {
$id_field = $this->db_fields['id'];
if (!empty($children[$element->$id_field])) {
$element->classes[] = 'menu-item-parent'; //enter any classname you like here!
}
parent::display_element($element, $children, $max_depth, $depth, $args, $output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment