I am including a custom menu in a wordpress theme – I want it to display the menu list items however, in the case that no items were added to the custom menu I want it to display nothing because I have a hard coded list item as well..
Here is the code I’m using
<ul>
<?php wp_nav_menu( array('menu' => 'Project Nav', 'container' => false, 'items_wrap' => '%3$s' )); ?>
<li><a href="www.website.com" title="Back to Website">Back to Site</a></li>
</ul>
It works to display the custom menu as only list items inside the hard coded < ul > however, if the custom menu is empty it reverts to displaying the main navigation list items…
How can I have it either display the items if they’re there, or display just the hard coded ‘Back to Site’ if the custom menu is empty?
Any help is appreciated.
Thanks,
Thomas
UPDATE: Found this out. Simple fix I overlooked in the Codex
<ul>
<?php $menu = wp_nav_menu( array( 'menu' => 'Commercial', 'container' => false, 'items_wrap' => '%3$s', 'fallback_cb' => false )); ?>
<li><a href="http://www.website.com" title="Back to Website">Back to Main Site</a></li>
</ul>
Just needed to add 'fallback_cb' => false to the options.
Just needed to add ‘fallback_cb’ => false to the options.