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
- How can I display a menu on certain pages only?
- Theme customizer – settings order
- Custom Image section in Customizer
- Add Caret to Menu Items with Sub-Menus in WordPress Theme
- Is it possible ( or advisable) to allow open access to the new theme customizer for potential clients?
- Add a dropdown to theme customizer
- wp_nav_menu sort order?
- Can I create customizer setting that can handle plugin shortcode?
- Editing the custom background CSS
- Is the theme customizer slowing down my site?
- Any walker causes blank menu?
- WordPress Customize — Move “menus” options / field to another section
- Changing the entire control choices using wp.customize with JavaScript
- How to remove menus section from WordPress theme customizer
- Get last modified date for menu link
- 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?
- “Display Site Title and Tagline” checkbox not working?
- Custom Nav Walker Displaying Values in Sub Menu
- Modify the Additional CSS section (adding a disclaimer)
- wordpress custom theme import and export options for sample data [closed]
- How to hook CSS file according to theme selection in the customizer section
- 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
- how to wrap tag in tag html to wordpress menu conversion
- after_setup_theme, Global Variable and Theme Customizer
- Set default screen option for appearance -> menus
- wp_nav_menu add something before closing container and after last list item
- Get a setting value conditionally in the Customizer api
- WP_Customize_Color_Control omitting # symbol
- WordPress empty Nav Menu error
- Primary navigation menu & footer not showing in category / tag page
- Theme-wide custom post template
- Disabling Customizer Selective Refresh shortcut icons for selected controls
- How to set the currently active page in the menu including parents
- Dynamically generated wordpress customizer options?
- Custom Navigation build using wp_nav_menu and walker
- Recommended method for updating/adding menus when adding new theme
- Why wp_nav_menu() doesnt show the proper meny when invoked two consecutive times?
- How to develop a menu like wwe.com?
- Why are some of my menu items not displaying on my menu?
- How to transfer one domain to another domain without losing theme options (customizer)?
- Thesis -style Navigation
- How to allow certain PHP functions when using sanitize_callback in the word press customizer
- How to allow users to create their own website within my domain? [closed]
- Doing context-aware previews in the WordPress Customizer
- Alignment Problem [closed]
- Avada Child Theme Development
- How can i make multilevel menu in wordpress theme with bootstrap
- Theme customizer – can’t add section/settings
- how do i develop a global nav and local nav to be wordpress dynamic?
- Theme logo metadata into template file
- WP Customazation API doesn’t save the default Value
- Adding content inside the anchor tags within WordPress main nav
- Why is my container argument not working for wp_nav_menu() [closed]
- Twenty Twelve Author not displaying
- How to Emulate Default Navigation Menu Behaviour in a Custom Theme?
- Custom nav menu not showing
- if (has_custom_menu())?
- Why do sticky posts show in this menu?
- Making a horizontal flyout menu from WordPress category listing
- Related Post Category Filter
- WordPress custom menu can’t show 3. level submenu
- how to create/register menu items that can be added to menus later
- Why nav_menu_css_class doesn’t work with apply_filters?
- Why does wp_customizer default values do not apply when theme is installed for the first time?
- Building a custom menu or use a plugin?
- Customizer API Multi Sections in single Panel
- Default customizer colors aren’t displayed outside of the preview
- Use instead of for wp_nav_menu()
- fetch all post from wp multisite network and sort all the post in descending order on the basis of “Created by ” term
- How Do I Create a WordPress Demo Site with Limited Admin Access
- What is difference between add_theme_support and Theme Customization API?
- (Parent) theme Is Not Showing In Theme Selection Panel and Therefore Breaks Child Theme
- How to show Custom Field Value in Woocommerce Shop Page
- Cold Fusion to WordPress
- How to show some of category in wordpress
- Text View (Code View) in WordPress Customizer TinyMCE Editor
- Menu names not getting translated
- Import settings from another theme
- How to know and change the machine name of a menu?
- Customizer Image-Picker Preview Not Working
- Correct was to customise theme using get_theme_mod in scripts
- How to get url image page the right way?
- Load get_page_templates into select menu
- WordPress Customizer Help with FontAwesome Icon
- “No Data Received” error in Chrome every time i try to update the theme functions file
- Problem with multiple menus in theme
- Main Menu Theme Different Output Print
- Menu item not created on theme activation
- How do I move menu to the bottom in Custom Community theme?
- Creating Multiple Menus in the Thesis Theme?
- How do I middle-align my header menu items in WordPress [closed]
- How do I make it super customisable?
- Add wrapper for a specific sub-menu
- How to show associated fields if checkbox is checked in customize widget screen using wp_customize?
- Dynamic nav menu with icons [closed]