I want to change the priority of the menus I have created in the nav_menus panel in the WordPress customizer.

I have tried all sorts of variations to:

$wp_customize->get_panel( 'nav_menus' )->priority = 1;

Nothing works. It seems nav_menus isn’t inside the class-wp-customize-manager.php document which is why I think it doesn’t work. Is there another way to access the nav_menus panel and all the menus inside that panel?

1 Answer
1

The Nav Menus panel is added at customize_register action priority 11, so you need to set the priority at priority 12 (or above).

This works for me:

<?php
add_action( 'customize_register', function ( \WP_Customize_Manager $wp_customize ) {
    $panel = $wp_customize->get_panel( 'nav_menus' );
    if ( $panel ) {
        $panel->priority = 1;
    }
}, 12 );

Leave a Reply

Your email address will not be published. Required fields are marked *