Skip to content

Instantly share code, notes, and snippets.

View ifkas's full-sized avatar

Ivo Culic ifkas

View GitHub Profile
@wpexplorer
wpexplorer / gist:6416006
Last active October 29, 2024 07:15
Add slug to menu ID for pages in WordPress menu
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;
}