I have a menu named “header-menu” and I only want this menu to be affected by the function I wrote below. How can I prevent other menu’s to be affected?

add_filter( 'wp_nav_menu_objects', 'header_menu' );
function header_menu( $items ) {
    $i = 0;
    foreach ( $items as $item )
        if($i == 6)
            $item->title = '<div id="end">.$item->title.</div>';
            $item->title = '<div class="link">.$item->title.'</div>';
    return $items;

I saw something about ‘wp_nav_menu_items’ and $items->theme_location that looks promising, but have no idea how to combine it.

Read more here: WordPress - customized wp_nav_menu for specific menu


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: