I have a WP 3.x site that I’m using mainly as a CMS. The menu links to the various WordPress pages.
One of the pages, “News”, is the “posts” page.
However, when clicking on one of the posts on the News page, the “News” item in the menu loses highlighting because the post isn’t treated as a child of “news”.
Is there an easy way to override the currently highlighted item in the menu? Ideally by forcing a page ID upon it.
Since I assume you’re using
wp_nav_menu()
, there should be a classcurrent_page_parent
which is applied to your posts’ page menu item when viewing a single post.You can use this class to style the ‘active’ state, much like you’re probably doing with
current_page_item
at the moment.If (for whatever reason) you must have
current_page_item
added too, you can filter thenav_menu_css_class
: