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

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

share|improve this question
    
Adding what classes? the only difference i can see between the two pieces of code you've posted is the ID attribute on the unordered list. –  t31os Feb 24 '11 at 18:04
    
That's correct, it adds id=menu-default, adding sf-menu to the second also didn't resolve the issue (as I thought it was suckerfish). Cheers –  Noel Tock Feb 24 '11 at 18:11
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
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.