Fallback_cb is messing around with containers

I have the following code in place for a custom menu area:

$wp_nav_header = array( 
    'container' => '',
    'menu_class' => 'sf-menu',
    'fallback_cb' => 'wp_page_menu',
    'theme_location' => 'primaryheader',
    'depth' => 0,);
wp_nav_menu( $wp_nav_header);

It works fine when there is a menu in place, and outputs:

Read More
<div id="nav-main">
<div class="sf-menu">
<ul><li...

However, when it’s falling back, it outputs:

<div id="nav-main">
<ul id="menu-default" class="sf-menu"><li...

Needless to say, this is throwing off my design as it’s adding these classes (for which I have no styling) & stripping suckerfish , but makes my nav disappear (despite showing up in source).

Anybody encounter this before?

Thank you!

Related posts

Leave a Reply

1 comment

  1. basically you are missing the container div so if you change your fallback to a custom function you can pass parameters to wp_page_menu that give you a bit of control over it and add your missing div try:

    $wp_nav_header = array( 
        'container' => '',
        'menu_class' => 'sf-menu',
        'fallback_cb' => 'my_fallback_menu',
        'theme_location' => 'primaryheader',
        'depth' => 0,);
    wp_nav_menu( $wp_nav_header);
    
    
    function my_fallback_menu(){
        echo '<div class="sf-menu">';
        $args = array(
            'sort_column' => 'menu_order, post_title',
            'menu_class'  => '',
            'include'     => '',
            'exclude'     => '',
            'echo'        => true,
            'show_home'   => false,
            'link_before' => '',
            'link_after'  => '' );
        wp_page_menu($args);
        echo '</div>';
    }
    

    Hope this helps