wp_nav_menu and fallback

I am using this code to call any custom menu and display:

<?php 
wp_nav_menu( array( 
    'container' => 'none', 
    'container_class' => 'menu-header', 
    'theme_location' => 'primary', 
    'menu' => get_post_meta( $post->ID, 'MenuName', true) ) 
); ?>

At the moment if there is no custom menu defined it falls back to the primary menu.

I am trying to edit this code, so if there is no custom menu then display nothing. Having no luck, doesn’t help that I’m new to php and wordpress. I have searched online and tried a few other solutions. Knowing my luck it’s probably something really simple.

If anyone could help me out, I’d appreciate it a lot!

Thanks

2 Answers
2

Simply set it to a predefined core-function that returns null or false:

'fallback_cb'     => '__return_zero'
// or
'fallback_cb'     => '__return_false'

Leave a Comment