page_menu_link_attributes WordPress Filter Hook
The page_menu_link_attributes hook allows you to modify the attributes of a page menu link. This can be useful for adding custom classes or data attributes to your links.
apply_filters( 'page_menu_link_attributes', array $atts , WP_Post $page , int $depth , array $args , int $current_page_id ) #
Filters the HTML attributes applied to a page menu item’s anchor element.
Parameters
- $atts
(array)The HTML attributes applied to the menu item's
<a>
element, empty strings are ignored.- 'href'
(string) The href attribute. - 'aria-current'
(string) The aria-current attribute.
- 'href'
- $page
(WP_Post)Page data object.
- $depth
(int)Depth of page, used for padding.
- $args
(array)An array of arguments.
- $current_page_id
(int)ID of the current page.
Source
Changelog
Version | Description |
---|---|
4.8.0 | Introduced. |