I have modified the function start_el in nav-menu-template.php substituting $item->ID with $item->title so that the html li elements in menu have a more readable class names. In detail, I have changed the line

$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );


$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->title, $item, $args );

This makes the editing of the style.css file for a theme easier. I wonder if it is possible to "transfer" the change from nav-menu-template.php to the theme (maybe functions.php?), so that I will not be forced to modify the file every time I upgrade WP version.

1 Answer 1


Simply add the following into your functions.php:

add_filters( 'nav_menu_item_id', 'wpse64308_nav_menu_item_id',10,3);
function wpse64308_nav_menu_item_id( $id, $item, $args){
    return 'menu-item-'.$item->title;
  • well that's much easier!
    – Milo
    Sep 6, 2012 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.