You’ll find it much easier to control which fields are shown, by controlling which walker is used. Rather than trying to ‘toggle’ the fields inside the walker.
I also wanted to show a bunch of custom fields, and only show them on a menu at a particular menu location. So I used the following…
add_filter( 'wp_edit_nav_menu_walker', function( $walker, $menu_id ) {
$menu_locations = get_nav_menu_locations();
if ( $menu_locations['main_menu'] == $menu_id ) {
return 'Walker_Nav_Menu_Custom';
} else {
return $walker;
}
}, 10, 2);
Related Posts:
- What is a good resource to find out about making custom walkers?
- Comment Walker vs. Comment Callback
- Why is my menu order not working with wp_nav_menu?
- Incrementing a class in a custom walker
- Adding ul class with wp_list_categories Custom Walker
- how to conditionally add attributes to start_lvl() function?
- Adding dynamic content to end_lvl in Walker Class [closed]
- Walker gives additional taxonomy name?
- $args->has_children not working with start_el()
- Limit Custom Crawler to front end only
- ol children instead of ul children
- Extend Walker Class for 2 checkbox taxonomy selection?
- using walker menu to add classes and attributes to elements
- Custom megameu walker need improvement
- List pages to show only Whitelisted sub pages
- Get Parent List Class for Child Pages Using Walker
- Manual use of Walker_Category class
- How do I get_the_content in a custom walker?
- Creating Custom navigation in wordpress with sub menus
- Page thumbnail doesn’t display on navigation
- How to remove ul & li from wordpress custom walker?
- Is it possible to display the Navigation Menu without using Walker_Nav Class
- Walker_Category – not reliably saving
- Custom Walker menu depth opening problem
- How to append something before final tag in walker class?
- Using wp_list_categories or other function inside a menu walker?
- Walker to add Bootstrap markup for wp_list_pages
- Help with output of post classes using apply_filters
- Custom walker pulldown display current page
- Custom Walker: how to get ID in function start_lvl
- Split up wp_nav_menu with custom walker
- Error “Trying to get property of non-object” with Custom Walker for wp_nav_menu
- Custom menu walker: how can i check first item
- Strict Standards Error bootstrap navwalker
- WordPress Menu Custom Walker Class
- Extend walker class with custom post types [closed]
- Term Checklist Walker – Disable Parent Categories
- Custom nav walker with different output depending on depth
- Add Thumbnail to wp_list_categories()
- Customize comment list markup
- Assign different category colours to different categories in the main menu
- Output the aria-labelledby parameter for a nav menu child
- Custom Nav Walker sub-menu HTML construct
- How to remove trailing tags from wp_nav_menu walker
- Editing or filtering the output of the Genesis navigation
- What does the “$depth” parameter in the Walker_Comment stand for?
- Custom Walker anchor tag not inheriting attributes
- Check what “type” a menu item is
- Adding ‘active’ class to custom taxonomies using walker in functions.php
- How to display dynamic content in start_lvl function
- Add custom text to menu
- How to add a tag to wp_nav_menu in a child theme
- Use wp_nav_menu to display ALL pages
- Third level navigation class
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- Run a filter when a walker runs
- Get top items number from wordpress menu
- Function issue with Walker_Nav_Menu [duplicate]
- add span class and i tag inside wp_nav_menu link anchor tag
- How to Overwrite/Customize wp-admin/nav-menus.php in WordPress
- Use menu class in walker function
- wp_nav_menu, walker class, categories as classes of li
- $item->url not retrieving url in custom walker?
- wp_list_pages() but only show children on the branch you are on
- Querying both pages and posts
- Walker class conditional based on parent menu item label or custom css class
- Sub Menu does not display using Nav Walker
- Put class on instead li
- Get Menu Name inside walker
- WordPress Menu Walker: add #hashes to child page links (only)
- WordPress Walker – Group two items?
- Where to implement custom walker class?
- cannot grab post meta from extended Walker_Category class properly
- Use custom walker to add taxonomy terms to main nav menu
- Walker Class – Check if menu item has description and if so add class to li
- How to add attribute in menu code
- Walker class for sub-menu with ACF fields
- Walker menu not displaying at all
- Add login hyperlink to secondary navigation menu
- Show Sidebar Menu Subpages When Clicking Parent
- How to request container_class from wp_nav_menu
- How can I make wp_nav_menu() support tags?
- How to Add support for sub-menu item description in wordpress?
- Adding a tag to wp_nav_menu
- How to exclude/remove submenu using Walker_Nav_Menu
- Why is my navigation in my onepage not working?
- Is it possible to get_the_post_thumbnail (Featured Image) inside a sprintf function?
- Need help with Walker_Nav_Menu class
- why are my walker menu is showing like this?
- Add parent menu item in sub-menu in custom nav_walker
- Add active class to wp_nav_menu
- Show post titles within WordPress bootstrap Dropdown menu
- Add parent link to its submenu
- Walker_Nav_Menu Add Strings and Class Name
- Count Level 1 Childs for Custom Nav Walker WordPress
- Need direction on a seemingly complex menu walker for automatically inserting a parent link li in it’s submenu ul
- I am extending Walker_Nav_Menu: How can I get the number of children elements of the current item?
- Navigation won’t update to show full path to single post
- Custom navigation / menu output (walker?)
- Using walker to display all menu branches at once?