Ok, so it turns out that by default, $depth
in the end_lvl()
function starts at 0 when it’s a submenu and increments as the depth gets greater. So we need to test if {$depth}
is equal to 0 to apply it only to the first set of submenus:
function end_lvl( &$output, $depth, $args ) {
if( 0 == $depth ) {
$output .= '<div>the div that I want to show only once</div>';
}
$indent = str_repeat( "\t", $depth );
$output .= "{$indent}</ul>\n";
}
Related Posts:
- Sub menu indicator that links to sub menu
- Looking replicate static HTML Menu into WordPress Dynamic Menu [closed]
- How can i create menu like in the example?
- Customize Widget Navigation
- Remove wrapping div and ul from output of wp_nav_menu
- How to add a new product type on woocommerce product types? [closed]
- WordPress hook before inserting post into database
- Making Custom Fields Standard in the Admin UI
- Add separator to admin submenu
- Why isn’t is_home() working correctly?
- wp_nav_menu() custom container and container_id
- Show a WP 3.0 Custom Menu in an HTML Select with Auto-Navigation?
- global menus made from master site’s custom menus wpmu network
- Adding Custom Link anchors in the top menu that points to specific sections of the site home page
- Any Hook Called When Post Becomes Published?
- When using the block.getSaveElement hook can you output different markup based on whether or not you are in the edit view or the live page view?
- wordpress custom walker for thumbnails with custom menu
- How to exclude certain widget from showing up on home/front page? [duplicate]
- Print shortcode in custom action hook not where the shortcode is entered
- Change default status and replace the icon for an hamburger menu
- simple expandable vertical menu, java script problem
- Disable email field on WooCommerce customer account details
- Schedule cron event from widget
- Customizing the default logout page of WordPress
- Is there a filter hook that I can use to change how taxonomy term names are displayed?
- wp_nav_menu google analytics event tracking
- Only append custom classes to nav menu items
- How to extend nav-menu-item-control data in Appearance > Customize?
- Hide Login information in Account settings in Buddy Boss
- Edit admin post page
- Admin Panel – Custom Menu Sub-Item LINK
- Adding all sub-pages to the menu manager
- add JS to multiple plugin admin pages
- Putting tag outside tag on generated Menu
- Programmatically (PHP) get the nr. of items in the primary navigation menu
- Single-level menu option? Another way?
- How to create left and right menu with logo center in a custom theme?
- How Do I Remove The Right Hand Block On The Main Header?
- Viewing checkout page removes fees from mini cart
- Adding posts to custom menu [closed]
- Remove add news page and posts from menu
- How to wrap the list with custom class using wp_nav_menu?
- Alphabetical Custom Menu
- Navigation label for page in custom theme
- WPML Plugin Not displaying multilingual Menus
- how to display a specific wordpress menu?
- Create a url structure for my blogs based on categories and sub-cats
- Custom font size nav bar
- Add child pages to submenu automatically
- Sticky menu for WP custom menubars
- Stop Expansion of Top Level Menu in the WordPress Admin Sidebar
- Insert menu with a custom walker into page / post body using shortcode?
- Implement a Walker with custom object rather than WordPress database object
- How can I tag a menu item as visited for each unique user?
- How do I create a root link in wordpress to a PDF file?
- Position a hard-coded menu item
- WordPress custom dropdown listings
- How to append custom text to the output of ‘categories widget’?
- How to request container_class from wp_nav_menu
- Menu not appearing in custom theme
- How can i display custom menu in sidebar?
- How to have multiple WordPress Menus
- How to load a mycred hook from a plugin?
- How to add active state to the navigation links?
- WooCommer Product Category Loop – How to change the display order of the rating and price?
- Removing Submenu from Menu
- WordPress menu: How to make www.link.com/#name never contain current_page_item class?
- Custom menu not showing even though it shows as being registered?
- How to make WordPress search page use a relative path
- Custom CSS Nav Menu Style Not Being Applied
- customer specific email attachment
- insert an HTML element if there is a submenu only
- Current menu item highlights wrong
- Add producthunt badge to wordpress menu
- Woocommerce custom “My Account” Tab – Add Save button
- How to add a template – so that i can choose a different menu for some pages
- clickable toggle menu, help
- How to create custom post type selection to nav menu
- Help needed creating a custom Hamburger menu in header
- Menu selection for header
- How to create a custom menu for specific user
- How to customize WordPress vertical menu?
- Creating a dynamic URL for an external link inside content
- remove or hide Link Relationship (XFN) form Menus tab
- Check get_post value after wp-admin login
- My connecting URL form in html to PHP does not work
- How to append the excerpt to the content in the single post page?
- User WordPress menu in custom page
- Adding images to anchors in the list created and fetched with wp_nav_menu
- WordPress menu walker – Get parent item text inside end_lvl function
- How do I display entries in the top menu based on conditions selected in the sidebar menu?
- Buddypress: New Tab and Page (Members Profile) [closed]
- Creating Action Hooks For Automatic File Inclusion
- How to work around the bug which prevents custom menus from being deleted?
- Class .current-menu-item in custom menu Walker
- Customizing the built-in Media Playlist
- How to move menu next to left of the search box?
- Custom CSS File wont work on second Page
- removing extra mobile menu from the header
- Custom Menu (only showing direct cildren) ACF not showing