apply_filters( 'nav_menu_item_attributes', array $li_atts, WP_Post $menu_item, stdClass $args, int $depth )
- Since
- 6.3.0
Filters the HTML attributes applied to a menu's list item element.
Compatibility
- WordPress
- since 6.3.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$li_attsarray- { The HTML attributes applied to the menu item's
<li>element, empty strings are ignored.
@type string $class HTML CSS class attribute.
@type string $id HTML id attribute.
}$classstringHTML CSS class attribute.$idstringHTML id attribute.
$argsstdClass- An object of wp_nav_menu() arguments.
$depthint- Depth of menu item. Used for padding.
Where this hook fires · 1
wp-includes/class-walker-nav-menu.php:228Walker_Nav_Menu::start_el()
Source code
* @type string $id HTML id attribute. * } * @param WP_Post $menu_item The current menu item object. * @param stdClass $args An object of wp_nav_menu() arguments. * @param int $depth Depth of menu item. Used for padding. */ $li_atts = apply_filters( 'nav_menu_item_attributes', $li_atts, $menu_item, $args, $depth ); $li_attributes = $this->build_atts( $li_atts ); $output .= $indent . '<li' . $li_attributes . '>'; /** This filter is documented in wp-includes/post-template.php */ $title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );Changelog
Introduced in 6.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.