WordPress: Highlight custom post type item in navigation

WordPress: Highlight custom post type item in navigation

Posted by on Mar 22, 2014 in WordPress | 0 comments

WordPress automatically assigns a css class of current_page_parent to navigation items of current pages. However it is not so kind when it comes to custom post types. I found a great little gist. It partially solved my problem, the custom post type item in my menu was now highlighted. However, going to the single page template for a custom post type would bring up a problem: both the current post type item was highlighted in the menu but so was the blog nav item. I thus modified the script to 1. use the default css class of current_page_parent and 2. I unset the css class unless the post type is actually post:

Post a Reply

Your email address will not be published. Required fields are marked *