Custom Post Types don’t highlight in menu nav

I have always considered this a bug, but if not, it’s pretty disconcerting. You have 2 things to fix: the first is to not highlight the “Blog” top-level item, and the second is to highlight the appropriate top-level item under which your single CPT resides.

There might be other methods, but I’ll share my method, which unfortunately, DOES target the menu ID’s with CSS.

To the nav container, add a conditional that identifies when the nav is being displayed on the single CPT:

<nav class="navsf<?php if (is_singular('news')) { echo ' fixhilite'; } ?>">

Then you’ll need to get the id’s for the “Blog” menu item and for the CPT parent Menu Item (in this example, “News”). Let’s say for “Blog” it’s the following:

<li id="menu-item-29" ...>

And for “News” it’s:

<li id="menu-item-30" ...>

In your CSS, you might target these items like so to change text or background colors to highlight/un-highlight things accordingly:

.navsf.fixhilite li#menu-item-29

.navsf.fixhilite li#menu-item-30