Visible Edit Shortcut for WordPress menu that uses nav walker

Nav menus in will use selective refresh by default when they are output into the page via wp_nav_menu() but with a few restrictions on the arguments. For the exact requirements on the $args, see WP_Customize_Nav_Menus::filter_wp_nav_menu_args().

In short, if you’re using a custom walker, then you need to pass it as a class name string instead of as an instantiated object. For example, instead of:

wp_nav_menu( array(
    // ...
    'walker' => new My_Custom_Walker(),
) );

Do this instead:

wp_nav_menu( array(
    // ...
    'walker' => 'My_Custom_Walker',
) );

Leave a Comment