public
Created

Adds a "has-children" class to menu items that have children. Posted by @chipbennet to the Theme Reviewers Mail List.

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
function oenology_add_menu_parent_class( $items ) {
 
$parents = array();
foreach ( $items as $item ) {
if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
$parents[] = $item->menu_item_parent;
}
}
 
foreach ( $items as $item ) {
if ( in_array( $item->ID, $parents ) ) {
$item->classes[] = 'has-children';
}
}
 
return $items;
}
add_filter( 'wp_nav_menu_objects', 'oenology_add_menu_parent_class' );

The arrows are working fine, but i had to make my menu larger and now the secondary dropdown overlaps with the first. Can you halp me find the CSS code to correct this please. ie how do you move the secondary dropdown in relation to the first.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.