1317 posts
  • Elite Author
  • Has been a member for 5-6 years
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a Free File of the Month
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
+1 more
fuelthemes says

I don’t know why but some of the wordpress menus always seem to display all pages if you have not assigned any menu to them.

Is there a way to prevent this behavior? Display nothing if no menu is assigned?

438 posts Don't be a HATER!
  • Exclusive Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 4-5 years
webinpixels says

I use my own function to detect if user have create the menu or not

function wip_have_custom_menu( $loc ){
    $locations = get_nav_menu_locations();
    $menu = "";
    if( isset( $locations[ $loc ] ) ) {
        $menu = wp_get_nav_menu_object( $locations[ $loc ] );
    }

    if($menu)
        return true;
    else
        return false;
}

use it in the file, eg the theme location is ‘primary’

if ( !wip_have_custom_menu('primary') ):
//echo some message, so user can create the menu
else:
    $nav_args = array(
        'container'       => '', 
        'menu_class'      => 'menu', 
        'menu_id'         => 'eqnav',
        'echo'            => true,
        'depth'           => 0,
        'theme_location'  => 'primary'
    );
    wp_nav_menu($nav_args);    
endif;

hope it help :)

good luck

3422 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Community Moderator
  • Bought between 100 and 499 items
  • Referred more than 2000 users
  • Has been a member for 4-5 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+4 more
sevenspark Volunteer moderator says

The wp_nav_menu function has fallback functionality built in. You can assign any function you want via the fallback_cb parameter. You can set it to false to disable the fallback. I assume that would print nothing :)

http://codex.wordpress.org/Function_Reference/wp_nav_menu#Parameters
1317 posts
  • Elite Author
  • Has been a member for 5-6 years
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a Free File of the Month
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
+1 more
fuelthemes says

I think I was looking for this function:

http://codex.wordpress.org/Function_Reference/has_nav_menu
by
by
by
by
by
by