prevent category page from also highlighting blog-page menu

Add this to your child theme’s functions.php:

add_filter('nav_menu_css_class', 'fix_category_menu_active_class', 10, 2);

function fix_category_menu_active_class($classes, $item) {
    // If we're on a category archive
    if (is_category()) {
        // Get the ID of the blog page (posts page)
        $blog_page_id = get_option('page_for_posts');

        // If this menu item is the blog page
        if ($item->object_id == $blog_page_id) {
            // Remove the active classes
            $classes = array_diff($classes, array(
                'current-menu-item',
                'current_page_item',
                'current_page_parent',
                'current-menu-ancestor'
            ));
        }
    }
    return $classes;
}

How it works:

  • It checks if you’re on a category archive.
  • Then removes the current-menu-item class from the blog menu item if it’s being wrongly marked active.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)