WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#16763 closed enhancement (worksforme)

nav-menu-template.php Does Not Add $class_names to Anchor Tags, Preventing Custom Theming

Reported by: obiwanmikenolte Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.1
Component: Menus Keywords:
Focuses: Cc:

Description

The $item_output portion of wp-includes/nav-menu-template.php that defines what the a tag will contain doesn't include a class attribute, whereas the ul tag does. This prevents customized theming (e.g. colors, images before/after, etc.) of the menu links. This can be modified by appending $class_names to $item_output's <a line, i.e.

$item_output .= '<a'. $attributes .'>';

becomes

$item_output .= '<a'. $attributes . $class_names .'>';

Change History (3)

comment:1 obiwanmikenolte3 years ago

  • Cc obiwanmikenolte added

comment:2 andymacb3 years ago

But the wrapping <li> is full of class names and also has a filter for adding your own, so your anchors can be targetted with li.the-class-you-want a {}

A.

comment:3 SergeyBiryukov3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

As andymacb pointed out, you can customize menu links using <li> tags' class names.

Note: See TracTickets for help on using tickets.