Home Forums WoodMart support forum Can’t add class to menu item link because the theme override the filter class

Can’t add class to menu item link because the theme override the filter class

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #660289

    maloneweb
    Participant

    Greetings,

    For some reason I need to add extra class to the menu item link, but the problem is:

    The theme override the filter nav_menu_link_attributes

    The problem:
    In the file inc/modules/mega-menu-walker/class-mega-menu-walker.php:402

    $atts          = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
    $atts['class'] = 'woodmart-nav-link';

    The theme will remove any class added by the filter and it will replace it with woodmart-nav-link

    The correct code should be:

    $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
    
    if ( array_key_exists( 'class', $atts ) ) {
      $atts['class'] .= ' woodmart-nav-link';
    } else {
      $atts['class'] = 'woodmart-nav-link';
    }

    Sincerely,
    Mohammed

    • This topic was modified 12 hours, 43 minutes ago by maloneweb.
    • This topic was modified 12 hours, 42 minutes ago by maloneweb.
    #660378

    Luke Nielsen
    Keymaster

    Hello,

    We will fix that in our next update.

    Thank you for your time and patience.

    Kind Regards

Viewing 2 posts - 1 through 2 (of 2 total)