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 function adds a home link into my nav menu, but it is added to 3 other menus I am using as well. I don't quite understand where to add code to only display in my primary nav.

function my_page_menu_args( $args ) {
    $args['show_home'] = true;
    return $args;
}
add_filter( 'wp_page_menu_args', 'my_page_menu_args' );
share|improve this question
    
Couldn't find an answer so I am now hiding the other home links with css. –  Drai Jul 26 '11 at 15:36
    
What function you use to display menus? I guess wp_page_menu right? –  Mamaduka Sep 24 '11 at 8:56
    
Yep the following code <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?> –  Drai Sep 30 '11 at 1:20

1 Answer 1

function my_page_menu_args( $args ) {
    if($args['theme_location'] === 'primary')
        $args['show_home'] = true;
    return $args;
}
add_filter( 'wp_page_menu_args', 'my_page_menu_args' );

The $args array also contains the theme location, so you can filter on that.

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.