Skip to content

Instantly share code, notes, and snippets.

@danemorgan
Forked from wpexplorer/gist:6416006
Created September 2, 2013 19:07
Show Gist options
  • Save danemorgan/6416235 to your computer and use it in GitHub Desktop.
Save danemorgan/6416235 to your computer and use it in GitHub Desktop.
add_filter('nav_menu_link_attributes' , 'att_add_menu_id', 3, 10);
if ( !function_exists( 'att_add_menu_id') ) {
function att_add_menu_id($atts, $item, $args) {
if( 'page' == $item->object ){
$id = $item->object_id;
$id = 'page-'. esc_attr( basename( get_permalink( $id ) ) );
$atts['id'] = $id;
}
return $atts;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment