Skip to content

Instantly share code, notes, and snippets.

@mauriciogofas
Created February 5, 2015 17:03
Show Gist options
  • Save mauriciogofas/42d737701dbed83fb6e7 to your computer and use it in GitHub Desktop.
Save mauriciogofas/42d737701dbed83fb6e7 to your computer and use it in GitHub Desktop.
Righlight Current parent and child menu
<?php
//Righlight Current parent and child menu
add_filter('nav_menu_css_class', 'add_active_class', 10, 2 );
function add_active_class($classes, $item) {
if( in_array( 'current-menu-item', $classes ) ||
in_array( 'current-menu-ancestor', $classes ) ||
in_array( 'current-menu-parent', $classes ) ||
in_array( 'current_page_parent', $classes ) ||
in_array( 'current_page_ancestor', $classes )
) {
$classes[] = "current-menu-item";
}
return $classes;
}
//END Righlight Current parent and child menu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment