This solution does almost what I want it to.
Only thing is, I have my menu set up as follows:
Menu item 1
Menu item 2
Custom post type 1
Custom post type 2
Custom post type 3
Menu item 3
Using the solution I mention adds the tag “current_url” to the sub menu of the custom post type I’m in (“Custom post type 1”). But I want it to add a “current_menu_item” (or something) to “Menu item 2”.
Any way to do this?
I do the following, it can be lengthy if you have many post types, feel free to edit it however:
WordPress handles this by adding the
current_page_ancestor
and/orcurrent_page_parent
class to the parent item. Try styling those classes similar tocurrent_menu_item
.