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?
- How to make a image-size selected by default in Media upload – WP v3.5
- Remove “Insert from URL” link in Media upload – WP 3.5
- static variable loop not working in WordPress
- Hide main div if wp_nav_menu is empty
- adding a filter to a shortcode?
- Check if a menu is empty?
- Change the footer text on the login page
- How to remove a metabox from menu editor page?
- add_filter to post-gallery and remove all ‘s?
- Walker class: Problems with understanding how walk() method can be called without error
- How to overwrite youtube embed?
- Rewriting search and pagination base
- Change comments form title on a page by page basis
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- Remove class that has been added by parent theme
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to add active class to custom menu using while loop and wp_list_pages
- How do I know what variables are passed in a filter/action and what their meaning is?
- WordPress menu deletes when trying to add a hook
- Logout and redirect using the WP Menu
- Have CSS Class Added with `is_page()` WP function
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Handling Body class based on Template
- Get_avatar filter?
- Input type search in Menu
- WP Walker using custom css classes
- How can I remove a function that has been added to wordpress with add_filter?
- How do I add custom bulk actions to multiple custom post types?
- 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
- 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
- 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 value to new attribute inside WordPress menu items
- How to have different site identity logos on each page on Astra Theme [closed]
- How to display different submenus?
- Extend Menu Walker Output
- Nav-Menu not showing up
- Remove submenu item from list
- 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?
- 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
- 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
- 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
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- How to pass value to add_filter wpcf7_form_tag from another function?
- Add text below WooCommerce short description if metabox value is true
- Is there a hook that I can use when a fatal error occurs?