Skip to main content
deleted 12 characters in body
Source Link
Ryan
  • 515
  • 2
  • 11
  • 22

I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing.

If I delete the menu, it will output a list of the pages.

Here's the code I've unsuccessfully tried:

<?php
if ( has_nav_menu( $theme_location ) ) {
    // User has assigned menu to this location;
    // output it
    wp_nav_menu( array( 
        'theme_location' => $theme_location, 
        'menu_class' => 'nav', 
        'container' => '' 
    ) );
}
?>

My functions.php file contains:

if (function_exists('register_nav_menus')) {
register_nav_menus (
array('main_nav' => 'Main Navigation Menu'));}

How can I use wp_nav_menu to only display a menu if one exists, otherwise show nothing?

I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing.

If I delete the menu, it will output a list of the pages.

Here's the code I've unsuccessfully tried:

<?php
if ( has_nav_menu( $theme_location ) ) {
    // User has assigned menu to this location;
    // output it
    wp_nav_menu( array( 
        'theme_location' => $theme_location, 
        'menu_class' => 'nav', 
        'container' => '' 
    ) );
}
?>

My functions.php file contains:

if (function_exists('register_nav_menus')) {
register_nav_menus (
array('main_nav' => 'Main Navigation Menu'));}

How can I use wp_nav_menu to only display a menu if one exists, otherwise show nothing?

I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing.

If I delete the menu, it will output a list of the pages.

My functions.php file contains:

if (function_exists('register_nav_menus')) {
register_nav_menus (
array('main_nav' => 'Main Navigation Menu'));}

How can I use wp_nav_menu to only display a menu if one exists, otherwise show nothing?

deleted 124 characters in body
Source Link
Ryan
  • 515
  • 2
  • 11
  • 22

I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing.

If I delete the menu, it will output a list of the pages.

Here are a couple of thingsHere's the code I've unsuccessfully tried:

<?php
if ( has_nav_menu( $theme_location ) ) {
    // User 
functionhas wp_get_nav_menu_object(assigned $menumenu )to {
this location;
    // output it
 if ( ! $menuwp_nav_menu( )array(  
        'theme_location' => $theme_location, 
        'menu_class' => 'nav',  
  wp_nav_menu( array( 'menu_class' => 'nav',  'container' => '' 
    ) ); 
}
?>

I've also triedMy functions.php file contains:

function wp_get_nav_menu_object( $menu ) {
    if ( ! $menu function_exists('register_nav_menus')
        return) false;{
    ifregister_nav_menus ( $menu )
    return wp_nav_menu( array( 'menu_class''main_nav' => 'nav', 'container' =>'Main ''Navigation Menu') ); 
}

How can I use wp_nav_menu to only display a menu if one exists, otherwise show nothing?

I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing.

If I delete the menu, it will output a list of the pages.

Here are a couple of things I've unsuccessfully tried:

<?php            
function wp_get_nav_menu_object( $menu ) {
        if ( ! $menu )            
             wp_nav_menu( array( 'menu_class' => 'nav', 'container' => '' ) ); 
}
?>

I've also tried:

function wp_get_nav_menu_object( $menu ) {
    if ( ! $menu )
        return false;
    if ( $menu )
    return wp_nav_menu( array( 'menu_class' => 'nav', 'container' => '' ) ); 
}

How can I use wp_nav_menu to only display a menu if one exists, otherwise show nothing?

I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing.

If I delete the menu, it will output a list of the pages.

Here's the code I've unsuccessfully tried:

<?php
if ( has_nav_menu( $theme_location ) ) {
    // User has assigned menu to this location;
    // output it
    wp_nav_menu( array(  
        'theme_location' => $theme_location, 
        'menu_class' => 'nav',  
        'container' => '' 
    ) );
}
?>

My functions.php file contains:

if (function_exists('register_nav_menus')) {
register_nav_menus (
array('main_nav' => 'Main Navigation Menu'));}

How can I use wp_nav_menu to only display a menu if one exists, otherwise show nothing?

Tweeted twitter.com/#!/StackWordPress/status/131827971559403520
Source Link
Ryan
  • 515
  • 2
  • 11
  • 22

wp_nav_menu: show menu only if one exists, otherwise show nothing

I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing.

If I delete the menu, it will output a list of the pages.

Here are a couple of things I've unsuccessfully tried:

<?php            
function wp_get_nav_menu_object( $menu ) {
        if ( ! $menu )            
             wp_nav_menu( array( 'menu_class' => 'nav', 'container' => '' ) ); 
}
?>

I've also tried:

function wp_get_nav_menu_object( $menu ) {
    if ( ! $menu )
        return false;
    if ( $menu )
    return wp_nav_menu( array( 'menu_class' => 'nav', 'container' => '' ) ); 
}

How can I use wp_nav_menu to only display a menu if one exists, otherwise show nothing?