If all of it is your own code then it would be reasonable to just implement that as part of walker.
If you need to add a filter while third party walker runs you could probably:
Add it at wp_nav_menu_args
hook, checking if walker
is set to that:
add_filter( 'wp_nav_menu_args', function( $args ) {
if ( $args['walker'] instanceof megaMenuWalker ) {
add_filter( 'wp_nav_menu_objects', 'callback_name_here' );
}
return $args;
} );
Remove it at wp_nav_menu
hook after the menu markup is completely generated:
add_filter( 'wp_nav_menu', function( $nav_menu ) {
remove_filter( 'wp_nav_menu_objects', 'callback_name_here' );
return $nav_menu;
} );
Related Posts:
- Mega Menu Walker
- start_lvl Ignored in Custom walker_nav_menu
- Automatically adding new post categories to menu
- Add data attribute to each li in menu
- Unique icons next to each WordPress menu item
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- Add item to top of menu using a filter in functions.php
- Add login hyperlink to secondary navigation menu
- Get the name of menu item with wp_nav_menu
- How to add aria role and schema markup to custom walker container
- Add parent menu item in sub-menu in custom nav_walker
- How to add different menu items on different menus?
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Can’t extend some core classes
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- Handling Body class based on Template
- Get_avatar filter?
- Add a class to the anchor tag on HTML5 gallery
- Menu — How to add “current-menu-grand-ancestor” css class
- Input type search in Menu
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- WP Walker using custom css classes
- add_action shortcut?
- How can I remove a function that has been added to wordpress with add_filter?
- How to control WordPress image metadata (using Imagick)?
- How do I add custom bulk actions to multiple custom post types?
- Removing “wpautop” (auto tags) only on certain pages?
- Custom Walker_Nav_Menu issue with variables on PHP 7.3
- Print last modified date only on posts
- How to add an arrow to menu items has submenus
- WordPress Gravatar filter is removing my custom attributes
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Child page menu in sidebar
- Title Case WordPress Menu Items
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Trying to store submenu items to render out after main menu
- How to change menu order item
- Redirect to another page using contact form 7? [closed]
- Alter required message using comment form api
- How to make modifications only to certain elements of an HTML string on the server-side?
- Override a function defined in wp-includes/comment-template.php
- Register a menu – Error Header
- Filtering a function’ output for a new continued function
- New walker for walker_nav_menu to change inside container data
- Deleting Certain terms from appearing on the front end as links
- Content filter won’t work
- Warning: in_array() null given in PHP function
- Upload multiple files in randomly generated folder using wp_upload_bits
- Create page template via functions.php?
- Add meta tags to a custom header
- Add value to new attribute inside WordPress menu items
- How to have different site identity logos on each page on Astra Theme [closed]
- Custom query vars filters problem with pagination
- How to display different submenus?
- How can I use custom menus with a Bootstrap WordPress theme?
- Extend Menu Walker Output
- Must filter functions receive all arguments passed to them?
- Nav-Menu not showing up
- Remove submenu item from list
- Dynamic Menu drops pages?
- Menu not styling. New menus functionality giving me a headache
- User filter posts by year
- Nav Walker that shows only children and siblings of top level parent menu item
- how to changes mobile menu toggle breakpoint in WordPress
- How to display already created menus via php?
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Adding markup to sub menu based on class
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Apply function.php filter only if url not has /amp/
- Change lost password url to a mailto URL in WordPress
- Remove span tags from WooCommerce Downloads page
- How to put 2 php codes in functions.php without site crashing
- Menu not updating for logged in users after redirect
- How to bind each “the_content” elements to a custom variables
- Reload page with a different shortcode when a user selects from a dropdown
- WordPress Ajax filter: Create two loops for different output styles?
- Add element after navigation element title don’t works like I expect
- How to disable sub menu items from being created?
- Difference between “Walker_Nav_menu” and “walker”
- Custom Bulk Actions handler not firing
- How to generate customized filtered output for the gallery
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- How to remove title tag with this filter
- str_replace not preserving whitespace
- Pulling a variable into the wp_nav_menu function
- How I can add div to menu?
- Woocommerce Price Text
- Limit Taxonomy Parents
- Display a post based on its metabox selection
- Add the “.current-menu-item” class to tag?
- Search box background on a different page template
- WordPress adding in site URL to header links
- Display a list of users with avatar filterable with alphabets
- Custom Links in Walker Class
- I am extending Walker_Nav_Menu: How can I get the number of children elements of the current item?
- AJAX: WordPress filters inside $html do not work as intended
- Assign new post author IF another user in custom field on post transition
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0
- How to pass value to add_filter wpcf7_form_tag from another function?