Last active
August 29, 2015 14:19
-
-
Save SeanChDavis/cd18834f235370a0bf37 to your computer and use it in GitHub Desktop.
Add HTML attribute to WordPress menu item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // DO NOT COPY THIS TOP LINE | |
function sd_nav_menu_attr( $atts, $item, $args ) | |
{ | |
// The ID of the target menu item | |
$menu_target = 99; | |
// inspect $item | |
if ($item->ID == $menu_target) { | |
$atts['attribute_name'] = "attribute_value"; | |
} | |
return $atts; | |
} | |
add_filter( 'nav_menu_link_attributes', 'sd_nav_menu_attr', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment