Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 );

to

$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

1 Answer 1

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

 
discard

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.