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

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


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.