Skip to content

Instantly share code, notes, and snippets.

@PlanBrewski
Last active December 14, 2015 22:58
Show Gist options
  • Save PlanBrewski/5161892 to your computer and use it in GitHub Desktop.
Save PlanBrewski/5161892 to your computer and use it in GitHub Desktop.
A quick explanation of how to use the WordPress wp_nav_menu's fallback_cb variable.
<?php
wp_nav_menu( array(
'menu' => 'top_menu',
'depth' => 2,
'container' => false,
'menu_class' => 'nav',
//Process nav menu using our custom nav walker
'walker' => new twitter_bootstrap_nav_walker()),
'fallback_cb' => 'wp_page_menu', // No menu available: will display all pages in menu
//'fallback_cb' => '__return_false', // No menu available: no output.
);
?>
@imamherlambang
Copy link

I think the 'fallback_cb' must be set inside the array, the code above is set outside array, look

new twitter_bootstrap_nav_walker()),

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment