Menu problem CSS choosing wrong current_page_parent
-
I’m using custom post types, but when selecting a custom post entry, my menu bar thinks I’m back in the “news” area of the site.
For example, when I’m on the landing page for the area in question, I get: http://www.evoenergy.co.uk/case-studies/ (with case studies selected as current page).
However, when I dig a bit deeper into the area, going to http://www.evoenergy.co.uk/system-type/on-roof/ for example, it highlights news, making me think I’m in the news area.
I’m pretty sure this is CSS related: when I’m in the “case study” area, the css says this for the news menu item: menu-item menu-item-type-post_type current_page_parent menu-item-2883
Any help MUCH appreciated!
-
No, I don’t think this is a css problem. You’ve written your css correct. The problem is that wordpress spots out wrong class as the current.
Are this pages or categories?
The problem is when you go to a single post, am I right?
You’ve probably choosed news as the single-post-page.Linosa
Thanks for the fast response!
It happens when I go to a category page: http://www.evoenergy.co.uk/system-type/on-roof/
Or a single post page:
http://www.evoenergy.co.uk/solar-pv-case-studies/20-x-solar-century-185-panels-in-gwent/The problem is I also have a news area, which needs to be set as news for single posts.
Is there a way to tell wordpress that these custom posts are “special” and should be treated differently to standard news posts?
Many Thanks
Tom
Yeah, I have the same problem myself. WordPress dosen’t understand by defaut which page it’s suppose to be.
I solved it by putting a class around my different single-pages and then used it for marking the menu. Like:
.interviews #menu ul li.menu-item-642 {background:#4e4e4e;}Guess there’s better way of doing it though. I just could’t come up with anything else.
is that along the lines of:
// Add current-menu-item functionality to custom post types add_filter( 'hybrid_body_class', 'add_to_body_class' ); function add_to_body_class( $class ) { global $post; // Use switch to filter through custom post types switch(get_post_type()) { case 'Films': // If custom post type is films, add current-menu-item class to body. $classes[] = 'current-menu-item'; break; } // return the $classes array return $classes; }it’s pretty annoying that it doesn’t see a custom post correctly…
Where did you find that?
Ok, that script is suppose to give the body tag an class.. am I right or wrong?
The topic ‘Menu problem CSS choosing wrong current_page_parent’ is closed to new replies.