I have a menu item that is a custom link. I want to add some CSS to this particular item only, so I'm going in and adding a CSS class through the menu. Without adding the class, the HTML looks like this:

<a href="#">My Menu Text</a>

When I add the class through the Menu editor, the resulting HTML looks like this:

<a href="#">
    <i class="no-hover"></i>
    "My Menu Text"

So I can't use the class to reference the <a> element. This is contrary to all of the doc that I've read, which all suggests that you can simply put the class into the menu item through the editor and then simply reference it in CSS.

Is this perhaps a strange feature introduced by a plugin I'm using, or is there something I'm missing?

  • Did you enable css class for menu item under Appearance > Menus (Screen option) and added the css class?? – Bikash Waiba Mar 30 '18 at 7:35
  • 1
    Normally, the class specified in menu editor, will be added to li element. Check, if your theme uses a custom menu walker. If it does, then analyze the code in it. What theme do you use? – Frank P. Walentynowicz Mar 30 '18 at 7:39
  • @FrankP.Walentynowicz That's what I thought, too. I'm using the kadence virtue theme. – BobRodes Apr 1 '18 at 1:03
  • @BikashWaiba Yes, I did. :) – BobRodes Apr 1 '18 at 1:04

The problem is an incorrect implementation of a menu item custom class by Virtue theme. Two changes are required in themes/virtue/lib/nav.php file. Replace line 30:

//$classes[] = $custom_class;


$classes[] = $custom_class;

Replace line 45:

$icon  = ! empty( $custom_class) ? '<i class="'. $custom_class . '"></i>' : '';


$icon  = '';

Note: to avoid your changes being overwritten by theme's update, create a child theme, and make your changes in it.

  • Hey, thanks, Frank! I appreciate your digging around. That works for me. That code certainly looks off. – BobRodes Apr 3 '18 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.