You can modify your menu by using walker.
include('subMenu.php');
$menu = wp_nav_menu( array('menu' => 'YOUR-MENU-NAME','menu_class' => 'megamenu','walker' => new subMenu));
create a file subMenu.php in theme folder add below code.
<?php
class subMenu extends Walker_Nav_Menu {
function end_el(&$output, $item, $depth=0, $args=array()) {
if( 'Item 3' == $item->title ){
$output .= '<ul class="sub-menu">
<li class="menu-item" id="menu-item-48"><a href="http://www.example.com/child1.com">child 1</a></li>
<li class="menu-item" id="menu-item-49"><a href="http://www.example.com/child2.com">child 2</a></li>
<li class="menu-item" id="menu-item-50"><a href="http://www.example.com/child3.com">child 3</a></li>
</ul>';
}
$output .= "</li>\n";
}
}
Related Posts:
- Some nav-menu filters do nothing
- Determine which theme location a wp_get_nav_menu_items is for
- How do I access the menus produced by Dashboard > Appearance > Menus
- Redirect to another page using contact form 7? [closed]
- Add child pages to submenu automatically
- WP_NAV_MENU filter targets all menus
- How to give a NavWalker its own stylesheet?
- add_menu_page() with different name for first submenu item
- Difference Between Filter and Action Hooks?
- How do I add CSS options to my plugin without using inline styles?
- How to create an API for my plugin?
- Is it ever okay to include inline CSS in plugins?
- How can I load a page template from a plugin?
- Change the_title() of a page dynamically
- Add custom menu item using wp_nav_menu_items filter
- How do I programatically insert a new menu item?
- Assign a Class to the Current “Tag” for Formatting
- Using query_vars filter
- Add Dividers or Separators Between Nav Menu Items
- Nav Menu meta failing to import
- How to get Post ID with the Add Filter Function
- Explanation of the “posts_join” and “posts_fields” filter hooks?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- add_filter OO with parameters
- How Can I Add a Filter to Class Instance Only?
- Is it possible to remove next-post / previous-post with out creating a custom template?
- How do I Make a Theme “plugin-ready”?
- How to remove unwanted panels inside InspectorControls from core blocks in Gutenberg
- function triggered by “manage_users_custom_column” filter not working
- Overwriting Core WordPress Functions with Plugins
- Proper way to use apply_filters() with class functions?
- add_filter and remove_filter added before and after wp_query
- How to modify post content before writing to database?
- How to apply a class to the second word in menu list item?
- Actions or filters fired when data is saved in a custom table
- Filter on the_content ignores shortcodes
- How to change wordpress post title?
- How to prevent loading of all plugin’s resources?
- What is the best way to provide plugin users with a way to customized the styles
- Display only certain posts based on visitor’s country?
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Conditional add_filter?
- Can I add pages to my custom menu via script?
- Replacing WordPress menu functionality with a plugin
- Is it possible to create an action hook using do_action() within add_action()?
- Hook for post permalink update
- Dynamically Override Fancy Title
- Calling apply_filters on non-documented hooks
- Hook event for upload image in the menu
- WordPress Media mime type filter problem 4.0
- How to allow Unfiltered HTML in a wordpress multisite install
- Why isn’t the Settings API designed to work for plugins using custom admin menus? [duplicate]
- What is better way to use Bootstrap inside admin panel?
- How do I approach removing menu items on the fly based on settings in my plugin?
- How to add custom content under plugin row in WordPress admin plugin list?
- Changing bloginfo description from a plugin
- wp_enqueue_style built in styles
- When at / ( or “home”) my menu doesn’t get a current-menu-item class
- What is the difference between current_page_parent and current_page_ancestor?
- Is there a way to verified if an add_filter is already applied?
- Define a function outside a class and call the function using action or filter hook
- Does add_filter work outside functions.php
- Synchronize Custom post type tags to WordPress default posts tags
- Delete a specific item menu when I deactivate my plugin
- How to restrict plugin’s sub-menu pages to admin/subscribers?
- multiple functions with same filter
- Woocommerce – Hide a Column in Cart Table
- Backslashes being stripped from CSS
- 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?
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- Header Button Chance Polylang Elementor
- Dequeue theme stylesheets but keep widget styling on custom page template
- How to check if a stylesheet is already loaded?
- PHP 7 – Class Method Compatibility Issue
- how to include javascript file and css file in wordpress
- How to add pages to custom menus on the fly [duplicate]
- How can I add a CSS rule to edit.php?
- 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
- add_filter : Passing an array instead of the callback function?
- Remove Internal Style Sheet if no Value Provided?
- How do I alter the comment form ‘allowed tags’ text in a plugin?
- How do I include background images in my stylesheets in a plugin?
- What parameter should I pass to wp_enqueue_style to depend on the themes stylesheet?
- WordPress after content Hook & external template part
- Namespaced action and filter tags
- Two functions utilizing registration_errors filter
- Is there a Filter that I can use to filter the tags before they are inserted in to the database?
- WordPress is automatically linking plain text email addresses
- best practice for query string values – get_query_var always empty for my value supplied in query string
- get_current_screen() return null
- Get Current Menu Location inside Nav_Walker
- Is there no admin ui guide for 4.x?
- Problems with: manage_${post_type}_posts_columns
- How To Change Logout Screen Title
- Add code inside specific wordpress standard function
- Adding custom fields to WordPress nav menus