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.

this code add the proper "home" to navigation... what i try to get is add home to ANLY the primairy navigation, how do i target the "main" only

function new_nav_menu_items($items) {
    $lang = qtrans_getLanguage();

    wp_nav_menu( array( 'theme_location' => 'primary', 'items_wrap' => '<ul><li id="item-id"><a href="$current_url">Home</a></li>%3$s</ul>' ) );
    $homelink = '<li class="home"><a href="' . home_url( '/' ) . $lang. '">' . __('Home') . '</a></li>';
    $items = $homelink . $items;

    return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
share|improve this question

1 Answer 1

up vote 0 down vote accepted

i did find my answer here : http://www.wpbeginner.com/wp-themes/how-to-add-custom-items-to-specific-wordpress-menus/

add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ( $items, $args ) {
    if (is_single() && $args->theme_location == 'primary') {
        $items .= '<li>Show whatever</li>';
    }
    return $items;
}
share|improve this answer

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.