Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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,
    Hafeez

    #663798

    Hey!

    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!
    Josue

    #663836

    Hi 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,
    Hafeez

    #664004

    Change 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;}
    #664007

    Hi Josue,

    That did it!

    You can close this topic now :)

    Thanks,
    Hafeez

    #664008

    You are welcome, glad to help :)

    Regards,
    Josue

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.