WordPress filter hook · part of WordPress core
page_menu_link_attributes
A WordPress core filter that 4 plugins also fire themselves, running on 13K+ sites between them.
“Filters the HTML attributes applied to a page menu item's anchor element.”
How to use page_menu_link_attributes
It's a filter: your callback receives the value and 4 more arguments, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'page_menu_link_attributes', function( $atts, $page, $depth, $args, $current_page ) {
// Change $atts here.
return $atts;
}, 10, 5 );Argument names come from EazyDocs's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
4 plugins that fire page_menu_link_attributes
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WPB Accordion Menu10,000+ installs
apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page_id )inc/helper/class.posts-walker.php:116 -
EazyDocs2,000+ installs
apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page )includes/Frontend/Walker_Docs.php:227 -
Waka Bulk Page1,000+ installs
apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page )includes/class-waka-bulk-page-walker.php:154 -
Online Help Sliding MenuFewer than 10 installs
apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page )OHSM_Walker_Pages.php:71
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.