Last active
December 14, 2015 02:09
-
-
Save frekw/5011834 to your computer and use it in GitHub Desktop.
A Wordpress nav_menu walker for adding parent classes to dropdowns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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