Menus panel in wordpress customizer

I am trying to remove Menus panel in wordpress customizer using below code but its not working.Someone please guide me.Thanks

$wp_customize->remove_panel( 'nav_menus' );

Related posts

2 comments

  1. There are 2 Trac tickets that govern this issue. The complete solution to this is

    add_action( 'customize_register', function( $wp_customize ) {
            /** @var WP_Customize_Manager $wp_customize */
            remove_action( 'customize_controls_enqueue_scripts', array( $wp_customize->nav_menus, 'enqueue_scripts' ) );
            remove_action( 'customize_register', array( $wp_customize->nav_menus, 'customize_register' ), 11 );
            remove_filter( 'customize_dynamic_setting_args', array( $wp_customize->nav_menus, 'filter_dynamic_setting_args' ) );
            remove_filter( 'customize_dynamic_setting_class', array( $wp_customize->nav_menus, 'filter_dynamic_setting_class' ) );
            remove_action( 'customize_controls_print_footer_scripts', array( $wp_customize->nav_menus, 'print_templates' ) );
            remove_action( 'customize_controls_print_footer_scripts', array( $wp_customize->nav_menus, 'available_items_template' ) );
            remove_action( 'customize_preview_init', array( $wp_customize->nav_menus, 'customize_preview_init' ) );
    }, 10 );
    

    More details:

    https://core.trac.wordpress.org/ticket/33552

    https://core.trac.wordpress.org/ticket/33411

    In the old versions of wordpress (<4.3) this worked, but not now:

    function your_customizer( $wp_customize ) {
    $wp_customize->remove_panel( 'widgets' );
    }
    add_action( 'customize_register', 'your_customizer' );
    
  2. Thank you dingo_d, that worked for me too.
    Incidentally, $wp_customize->remove_panel('widgets); still works in WordPress v. 4.5.1

Comments are closed.