Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6651109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:58:17+00:00 2026-05-26T00:58:17+00:00

I am including a custom menu in a wordpress theme – I want it

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:58:18+00:00Added an answer on May 26, 2026 at 12:58 am

    Just needed to add ‘fallback_cb’ => false to the options.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm to get a custom DateTime format including the AM/PM designator, but I want
I've a custom webserver which parses HTTP requests including multipart-form data. In case of
I'm creating a custom control that contains other controls, including two scroll bars, one
I have created a default style for a Button including a custom ControlTemplate like
Is including a application package prefix while defining a custom action string is convention
Including DISTINCT to an SQL query that also uses ORDER BY CAST(thecolumn AS int)
I'm including a PHP script that changes the URL. // index.php ob_start(); include script.php;
I have a MaskedTextBox control that, in our case, is collecting social insurance (tax)
I work with a client that is using purchase orders, and a custom order's
Using our custom Drupal module to display tabular information pulled via another server's view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.