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 am trying to create a child theme so theme updates are much easier. I want to remove the parent theme menus and add my own. I know I can modify the header.php file (where these menus exist) and edit the wp_nav_menus directly, but I'm trying to avoid using as many theme files as possible, so I'm trying to accomplish this in my functions.php file.

Using unregister_nav_menu I am able to remove the menu from the parent theme location as such:

function RR_remove_parent_theme_menus()     {
    unregister_nav_menu( 'top-menu' );
    unregister_nav_menu( 'header-menu' );
}
add_action( 'after_setup_theme', 'RR_remove_parent_theme_menus', 20 );

This works great for "top-menu" but "header-menu" is coded in the parent theme with a custom fallback. Is there any way to override a custom (or a default) menu fallback using unregister_nav_menu or something else?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You can filter 'wp_nav_menu_args', set an invalid theme_location and the magic function __return_false as fallback:

add_filter( 'wp_nav_menu_args', 'override_parent_args' );

function override_parent_args( $args )
{
    if ( 'header-menu' === $args['theme_location'] )
    {
        $args['fallback_cb']    = '__return_false';
        $args['theme_location'] = 'ticky_tacky';
    }

    return $args;
}
share|improve this answer
    
How would I filter it to be /completely/ gone? I don't want any remnants of the container or the contents in there. –  RodeoRamsey Apr 30 '13 at 19:36
1  
@RodeoRamsey Maybe an invalid theme_location with __return_false as fallback_cb? –  toscho Apr 30 '13 at 21:28
    
That did it! :) Thanks all! –  RodeoRamsey Apr 30 '13 at 21:39
add comment

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.