WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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;
share|improve this answer
well that's much easier! – Milo Sep 6 '12 at 0:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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