This is due to the wp_nav_menu
parameter fallback_cb
:
If the menu doesn’t exist, a callback function will fire. Default is ‘wp_page_menu’. Set to false for no fallback.
You have not specified an alternative, so it uses the default, wp_page_menu
.
You could create your own function to display a page menu with the proper markup, or set the fallback_cb
parameter to false
and display nothing.
has_nav_menu
might also be helpful for displaying alternate markup when a menu isn’t available.
Related Posts:
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- How to add background image control to page admin controls?
- Is there a way to add a class to non current menu item?
- Redirect to another page using contact form 7? [closed]
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Functions php shortcode for displaying main menu with no child items
- Nav menus all outputting the same links
- Show some menu sub items as dropdown under a menu item
- How to insert class in each list of categories?
- I can’t add CSS with functions.php
- Default Nav Highlight
- call_user_func_array() expects parameter 1 to be a valid callback, function
- why can’t i add front.css to my frontpage.php
- wp_nav_menu work in functions.php but not in the theme
- current_page_item is missing inside wp_nav_menu
- define css class in functions.php
- Advanced method to control cache of enqueued style/script
- wp_nav_walker that interacts with widgets to setup mega menu
- Display random categories on the front page (Finding and Editing Theme Functions)
- Remove Container Element From wp_nav_menu() Markup
- How to get woocommerce inventory status [closed]
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- How to target specific wp_nav_menu in function?
- How do I create a new WP admin color scheme?
- Add attribute to link tag that’s generated through wp_register_style?
- Organize functions.php
- How to override functions.php in child theme?
- How to activate “Description” metabox for menu item programmatically?
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- automatically adding submenu items
- Child Theme Not Overriding Parent Theme
- How to programmatically set a menu to be the Primary Menu?
- Dequeue script in template isn’t working
- Changing itemprop from logo to image on custom logo?
- Make menu structure match page heirarchy on page parent change
- Where is definied the theme location for the main menu in a WordPress template?
- How to call custom function from functions.php in site-wide template files?
- Menu fallback “menu_class” rendering a “div” instead of a “ul”
- Displaying theme options in css
- Create wordpress header with custom logo in between the menu splitting the menu into two equal parts [closed]
- How to enable template page only for a post id page
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- enqueue styles for only mobile wp
- Jquery implementation not working on page reload
- Generating dynamic css into custom file [closed]
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Removing specific menu items?
- Is my code correct to enqueue CSS on a specific page?
- Check if the image size is available and if not use ‘full’ image size
- Remove Custuomize Sections
- Can we create our own theme’s function.php?
- Not all CSS elements transferring via parent to child?
- Define PHP variable from a seperate API if statement
- get_pages() Returns Only One Item
- Split Media Queries in different files!
- Filter nav menu items HTML tags and wrap inner text with span
- Change menu based on page template via functions.php
- How to add custom li item to wordpress menu
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- Parent theme styles overriding child theme CSS [closed]
- Theme JS is available but theme CSS isn’t
- Proper Way to Load stylesheet on Condition
- Getting the teaser text without overriding global variables
- Adding theme option values as custom body class
- How to modify mobile nav menu text in theme
- Adding a section in line at the end of the main navigation menu in php
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- What is the correct way to include my new functions and scripts in WordPress?
- Unable to add extra elements to the main navi (wp_nav_menu_items)
- Custom Menu in Admin doesn’t change menu in browser
- Conditional custom menu?
- How to add or delete default value theme options while activate and deactivate theme
- wp_nav_menu displaying all pages
- Warning at top of website & top menu gone
- How to display an image before title text in menu items
- WordPress wp_dequeue_script remove all other scripts
- Why nav_menu_css_class doesn’t work with apply_filters?
- Can’t load assets
- CSS style and app.js not loading
- How to automatically add counted number to navigation menu items?
- Menu and category highlighting for a single post
- How to add styles in existing function?
- Child Theme not loading multiple stylesheets
- How to retrieve image IDs from shortcode content?
- Correct way of Enqueue self hosted fonts in sass project
- Class::$template_dir_path=get_template_directory();
- Language Switch Function
- wordpress not calling peliegro functions.php?
- Language switcher for subdomains
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Modify sub_menu function to show pages below a specifically set page
- Functions.php in child theme that loads CSS file breaks website
- How to add a class name to the ancestor of a post?
- Function Reference for custom link in Admin Menu Management Page
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- Add custom css to theme
- How to get postId from the argument $block when register_block_type()?
- WordPress is adding pagination for all pages not only for blog page, How to remove pagination for all pages except blog/posts page?