You must use wp_nav_menu()
if you want to get selective refresh (fast previewing). If you want to have a custom nav menu that uses selective refresh, then instead of manually iterating over wp_get_nav_menu_items()
you instead need to subclass the Walker_Nav_Menu
to implement your custom logic, and then pass it into wp_nav_menu()
like this:
wp_nav_menu( array(
'theme_location' => 'primary',
'walker' => 'My_Custom_Nav_Menu_Walker',
) );
Here’s one example of creating a custom walker: https://wordpress.stackexchange.com/a/116719/8521
Note that you must pass the walker class as a string and not an object in order for selective refresh to be available. See full conditions.
Related Posts:
- Override customizer values on a per-menu base
- Menu items description? Custom Walker for wp_nav_menu()
- How to add posts to custom menus?
- How To extend WP_Customize_Control
- wp_nav_menu(), how to change class?
- Display Menu Name using wp_nav_menu
- How do I remove a pre-existing customizer setting?
- How can I display a menu on certain pages only?
- Theme customizer – settings order
- Custom Image section in Customizer
- Get entered value of customiser field for live preview
- Add custom classes to anchor in wp_nav_menu
- Add Caret to Menu Items with Sub-Menus in WordPress Theme
- How to remove the Theme Customization Button from the dashboard and themes options page?
- Is it possible ( or advisable) to allow open access to the new theme customizer for potential clients?
- How to limit wordpress menu depth in admin panel
- Add a dropdown to theme customizer
- Theme Customizer : how to create multiple-level panel
- Allow Shortcode in Theme Customizer
- Theme Customizer – Nested Sections?
- wp_nav_menu sort order?
- Customizer Active Callback not working
- Can I create customizer setting that can handle plugin shortcode?
- How to determine if custom menu is active?
- How do I check if a menu exists?
- Editing the custom background CSS
- How to use logout function on custom menu link?
- How to execute conditional script when on new customize.php (Theme Customize) screen
- Is the theme customizer slowing down my site?
- Trigger Customizer saving process with Javascript only
- Adding customizer styles with wp_add_inline_style
- Any walker causes blank menu?
- How to display wp_nav_menu() conditionally only when not on a 404 page?
- How to add menu support to a theme?
- WordPress Customizer Typography: How to load just the unique Google Fonts?
- WordPress Customize — Move “menus” options / field to another section
- Can we add more than one control under a setting in WP theme customizer?
- Widgets panel not displaying in the Theme Customizer
- Problem with registering menus – What to do when other solutions aren’t working?
- Add a #hash to the links in my custom menu
- How can i change menu link when page content empty?
- Is it possible to display the admin bar while in the Theme Customizer?
- How do I get a parent theme modification from a child theme?
- Select menu on browser resize
- Changing the entire control choices using wp.customize with JavaScript
- How to Change CSS Variable value in Theme Customizer Live Preview
- Extend walker – navigation, adding data attribute to a tag
- How to remove menus section from WordPress theme customizer
- How to add (css) classes to only one wp_nav_menu()?
- Get last modified date for menu link
- Replace Home with image link inside custom header menu
- Get background color for Live Preview with Theme Customization API?
- Displaying wp menus by name without using theme locations
- Checking if there is an Image inserted – if not don’t display anything
- How to add nofollow to wp_nav_menu
- How to highlight the current page in the nav menu?
- How do I add a post to a menu
- “Display Site Title and Tagline” checkbox not working?
- how to change WordPress menu markup/classes
- Setting a Default ‘Theme Location’ When Creating a Menu
- WordPress nav_menu_css_class theme filter is not being called
- How to set page template on front using starter content?
- Default header image does not display
- WordPress Customizer Control with React
- Responsive Images – Generating multiple images from Theme Customizer control upload?
- Modify Javascript Configuration Options for Theme Customizer Colour Picker
- Best practices: Custom theme sidebar menu – hardcode or widget?
- How do I highlight the menu for a child page?
- Custom Nav Walker Displaying Values in Sub Menu
- Modify the Additional CSS section (adding a disclaimer)
- How to change the customizer´s sidebar width?
- Theme Customizer – Choose where widget area appears, to let users organise widgets
- how to set more than one menus to the same theme location
- Custom Nav Walker to show siblings and children of current branch?
- wordpress custom theme import and export options for sample data [closed]
- How to hook CSS file according to theme selection in the customizer section
- How i can get widgets areas working in customizer?
- How Can I Create a List of Values to Be Iterated Through via WordPress Customization API?
- Change setting name in Customizer and keep the data
- CSS won’t style output of wp_nav_menu() correctly
- Create self-populating menu and add extra divs to the menu layout
- Where is definied the theme location for the main menu in a WordPress template?
- how to wrap tag in tag html to wordpress menu conversion
- Second menu not showing
- How to remove class attributes from custom menu markup?
- after_setup_theme, Global Variable and Theme Customizer
- Custom Script Section Only Echoes Text
- How to disable automatic colors in the Twenty Twenty theme?
- 2 differen’t menus and it’s using same items in both
- WordPress not registering Theme Customization Section
- menu behavior is not as expected
- Is there an action for save_menu and/or update_menu?
- Set default screen option for appearance -> menus
- Part of Menu Item Hidden on Header Menu
- How can i add edit shortcut icon in wordpress customizer without using selective refresh?
- wp_nav_menu add something before closing container and after last list item
- Add new panel inside parent panel in WP Customize?
- WP Customize refresh problem
- Input ordering in wordpress theme customizer
- Unable to pass variable on theme cusomizer add_settings()