Skip to content

Instantly share code, notes, and snippets.

@pixeldevsio
Created April 25, 2021 21:19
Show Gist options
  • Save pixeldevsio/a20e7c7a28bceb737a2f99b7de889ebd to your computer and use it in GitHub Desktop.
Save pixeldevsio/a20e7c7a28bceb737a2f99b7de889ebd to your computer and use it in GitHub Desktop.
<?php
// Highlight menu item if child is loaded
function custom_active_item_classes($classes = array(), $menu_item = false){
global $post;
$classes[] = ($menu_item->url == get_post_type_archive_link($post->post_type)) ? 'current-menu-item active' : '';
return $classes;
}
add_filter( 'nav_menu_css_class', 'custom_active_item_classes', 10, 2 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment