This will add class sub-menu-0
, sub-menu-1
and so on depending upon their depth.
//This will go in functions.php file
class wpse61220_submenu_class extends Walker_Nav_Menu {
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"sub-menu-".$depth."\">\n";
}
}
// Usage -
// wp_nav_menu( array('walker' => new wpse61220_submenu_class() ) );
Reference – function wp_nav_menu()
Related Posts:
- add_menu_page() with different name for first submenu item
- How to add sub-menu to a menu generated by wp_nav_menu by using plugin
- Change the_title() of a page dynamically
- How do I programatically insert a new menu item?
- Add Dividers or Separators Between Nav Menu Items
- Nav Menu meta failing to import
- Overwriting Core WordPress Functions with Plugins
- Some nav-menu filters do nothing
- Determine which theme location a wp_get_nav_menu_items is for
- Can I add pages to my custom menu via script?
- Replacing WordPress menu functionality with a plugin
- Hook event for upload image in the menu
- Why isn’t the Settings API designed to work for plugins using custom admin menus? [duplicate]
- How do I approach removing menu items on the fly based on settings in my plugin?
- What is the difference between current_page_parent and current_page_ancestor?
- Delete a specific item menu when I deactivate my plugin
- Create a Page via plugin
- Add Submenu Link in add_submenu_page That Opens in a New Window
- How to assign a WP 3.0 custom nav menu to a theme’s navigation menu location via script?
- Header Button Chance Polylang Elementor
- PHP 7 – Class Method Compatibility Issue
- How to add pages to custom menus on the fly [duplicate]
- How do I add a custom sublevel menu specified in one directory to a custom top level menu specified in another directory?
- Add notification bubble notice in navigation using transients
- Get Current Menu Location inside Nav_Walker
- Adding custom fields to WordPress nav menus
- Sub Menu content is being duplicated
- Plugin menu addition in multisite
- Remove unwanted elements for a wp_nav_menu
- Is this best practice for Dynamically adding items to WordPress menus?
- How to remove or add submenu item on plugin activate or deactive
- Custom code for WordPress dynamic menu
- How do I access the menus produced by Dashboard > Appearance > Menus
- wordpress add_submenu_page adds broken link
- WP Enqueue style on all plug-in pages
- Add child pages to submenu automatically
- Customize existing menu item
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- Issue with plugin sub menu and pages
- How to add Plugin functionality in WordPress Frontend Menus
- How to hide page links from theme menu
- WP_NAV_MENU filter targets all menus
- How do I add a menu item to a Pods admin menu?
- Add user managable titles to custom menus?
- How to create archive page to add in menu
- How to show only the last two categories in a menu?
- Always hide a page from the menu
- remove different admin menu for specific users
- How to get an array out of a nav menu if it’s a plugin?
- What happens when you create/edit a menu
- Plugin admin list pages as submenu
- Adding parent custom post type menu option
- Create and style menu
- Invalid Menu Items
- Declaration of mandoe_menu_walker::start_el(&$output, $item, $depth, $args) must be compatible with Walker::start_el(…)
- Custom Nav Walker $item->url producing malformed hyperlinks
- Displaying an Uploaded Image as a Custom Avatar in WordPress
- Adding a navigation with wp_nav_menu() to a custom block in the site editor
- How to output message during plugin activation
- How to provide translations for a WordPress TinyMCE plugin?
- Where do I start from
- Change of query var in pre_get_posts not maintained
- Hook for post permalink update
- Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page
- Load page template with custom content using a plugin
- Will changing the ‘Plugin Name’ header in the next update of a plugin break anything?
- Performance of several get_option() calls
- Problem with is_active_sidebar?
- Prevent Plugin from loading on ‘wp-admin / wp-login’
- Getting admin notices working for plugin errors
- override pluggable.php functions
- An echo line in a transition_post_status action leads to “cannot modify header information – headers already sent by”
- “Plugin could not be activated because it triggered a fatal error.”
- How to remove the current post from the query?
- Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?
- how to get up row in wordpress with wpdb
- Preview plugin store details
- Get attachments from a post
- How to remove default style of header in wordpress metabox
- wp_update_post deletes post meta in CPT
- flush rewrite rules after plugin update?
- hook filter after the_content on a specific page
- Run command “composer install” when activating wordpress plugin
- WordPress dynamic widget by location?
- Development plugin to view and manage scheduled wordpress cron jobs?
- Custom Icon for Plugin
- WP_Query order posts by category
- How to override supports of innerBlocks?
- Implications of creating a plugin that adds functionality to other developer’s plugin?
- why is update_user_meta creating arrays when trying to change the same value?
- WordPress OOP get current user question?
- Including content into an add_shortcode() function
- Override WooCommerce files from plugin
- Add WordPress Meta Box saved form input to WordPress RSS feed [duplicate]
- What should I use instead of get_blog_option?
- Children Shortcodes?
- Ajax functions – no access to wp-admin.php only online
- Create wordpress dashboard metabox which spans all columns
- add_filter adds output in the head
- How can i add insertion point between inner blocks in my custom block like core blocks