Tagged: active, category blog post, menu
-
AuthorPosts
-
July 20, 2016 at 12:29 pm #662914
Hi Enfold Team,
I’ve set the blog page to: News & Promo page which lists blog category posts in grid layout using ALB.
I also have another page called Events & Rides which lists blog category under the same name in grid layout using ALB.
The problem is, when I view a post under events & rides category, the highlighted menu is News & Promo and not Events & Rides menu.
I would like for every post under events & rides to be highlighted under the correct menu in main menu.
I have tried previous suggestion for the menu to be changed to blog category menu with redirection to the ALB page, but it’s not working.
Can you help to achieve this?
Thanks,
HafeezJuly 22, 2016 at 11:25 am #663798Hey!
Try adding this at the very end of your theme / child theme functions.php file:
function add_category_name($classes = '') { if(is_single()) { $category = get_the_category(); $classes[] = 'category-'.$category[0]->slug; } return $classes; } add_filter('body_class','add_category_name');
That should set the category slug as a body class, that way you’d know if a Post of certain category is being show and adjust the CSS accordingly:
#top.category-events-rides #header .av-main-nav > li > a {color: #808080;} #top.category-events-rides #header .av-main-nav > li#menu-item-523 > a {color: red;}
Makes sense?
Cheers!
JosueJuly 22, 2016 at 12:53 pm #663836Hi Josue,
Thanks for your reply :)
I’ve put the code in the functions.php and the css in the quick css area.
Unfortunately it’s not working.
Can you take a quick look?
Login credentials in the private area.
Thanks,
HafeezJuly 22, 2016 at 5:50 pm #664004Change the CSS code to:
#top.category-rides #header .av-main-nav > li > a {color: #808080;} #top.category-rides #header .av-main-nav > li#menu-item-523 > a {color: red;}
July 22, 2016 at 5:55 pm #664007Hi Josue,
That did it!
You can close this topic now :)
Thanks,
HafeezJuly 22, 2016 at 5:56 pm #664008You are welcome, glad to help :)
Regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.