3

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?

3

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.