Custom post types and active menu items
-
Hi, I was wondering how other people are setting up their main navigation menus while using new Custom Post Types. I can’t seem to make the relevant primary navigation menu items active when looking at a custom post type.
My primary navigation is thus:
Home – Blog – Mix TapesMy ‘Home’ page is an actual ‘page’ and is the landing page due to my settings in Settings / Reading.
My ‘Blog’ page contains the actual blog, also set up in Settings / Reading.
My ‘Mix Tapes’ links to a page which starts a loop with this:
query_posts(‘post_type=mix_tapes&posts_per_page=4’);
which lists posts of a custom post type ‘Mix Tapes’.So far so great, but when I click on a Mix Tape post the ‘Blog’ menu item becomes active. Is there any way to associate a post type of ‘Mix Tapes’ with the menu item of ‘Mix Tapes’ above?
Both wp_nav_menu and wp_page_menu don’t seem to do this. And the only solution I can see so far is to hand code a navigation menu with a bunch of conditionals like:
if ( ($post_type == ‘mix_tapes’) || (is_page(‘Mix_Tapes’)) ) {
$mix_tapes_menu_item = ‘active’;Any suggestions?
- The topic ‘Custom post types and active menu items’ is closed to new replies.