2

I'm building a site that has a two level menu created with the admin Menu tool. The menu contains links to both Pages and Category lists. It doesn't link directly to Posts. The problem is that when you drill down into a Category list and click to view a single post in that Category, the menu highlighting gets it wrong.

I've tested on a new install of WP3, set up a simple test site with a few pages and posts in 3 categories. All I've changed in the theme is the style.css to highlight the whole path.

http://danwashere.com/wp_dev/

Here's a direct link to view a categorised post here:

http://danwashere.com/wp_dev/2011/07/28/blue-rocks/

Everything is a page, except with the section "Advice Categories" - all those sub items are category lists containing categorised posts - each post is only categorised with a single category. The menu structure is defined entirely in the Menu settings. On that Blue Rocks page, the menu should be highlighted like this: Advice Categories -> Rocks, but it's highlighting the Sample Page item. And if you rollover the "Advice Categories" menu, you'll see that it is correctly highlighting the "Rocks" menu item.

It seems to me that WP is applying the 'current-post-parent' class to the wrong top menu item, but maybe I'm missing something?

// Edit, rewrite to make it clearer.

Dan Searle
  • 546
  • 2
  • 5
  • 14

1 Answers1

0

It seems as though were both having very similar issues. - Trouble highlighting correct menu parent with wp_nav_menu classes while viewing “single posts”

Im not using categories as links in my menu but I use them to filter content to each page via query_posts...if you examine the output from Wordpress you'll notice its actually placing the current page class onto the incorrect li tag when viewing a single post - Is this happening to you as well?

Community
  • 1
  • 1
Mr.Brown
  • 179
  • 3
  • 11
  • I haven't tried having single posts linked directly in the menu, just pages and category lists. It correctly highlights the category list but highlights the wrong top level menu item. I'll try to recreate your bug too next week, I guess they might be related. – Dan Searle Aug 05 '11 at 08:15
  • Im starting to gather that this has something to do with the posts all thinking they belong to "blog or home"...Maybe its because query_posts effects global variables and template tags in a different way? – Mr.Brown Aug 05 '11 at 21:41
  • well I'm not using query_posts so I wouldn't know - my test here is just using plain wordpress settings via the admin. I deliberately stripped it all down to make sure it was something in WP rather than my own code. – Dan Searle Aug 09 '11 at 15:16
  • I actually ended up using WP_Query instead for all my custom page loops and the menu still ends up having the same results, I believe its a bug at this point to be honest. – Mr.Brown Aug 09 '11 at 17:40
  • I'm going to put it to the wp-hackers list, to see if someone can pick it up. Cos I'm now considering writing SQL queries to walk thru the menu in a walker class, and it seems like it's silly that I'd have to do that, I can't believe we're alone with this problem! But my Googling takes me to yet more posts from you on different sites :-) – Dan Searle Aug 10 '11 at 17:07
  • Yeah, I kinda decided to move on since I was spending too much time on the issue and needed to finish developing this theme to meet my deadline...as of now, im just not utilizing any current page highlighting classes since it seems unattainable at the moment. – Mr.Brown Aug 11 '11 at 21:31