Remove ‘Menus’ from Twenty Sixteen theme Customizer

Thanks Dharmishtha, but I found the answer in below stack which worked really well without throwing any debug errors:

How to remove menus section from WordPress theme customizer

The correct way to disable ‘Menus’ and ‘Widgets’ (in Customizer) lies in creating a plugin with below code (taken from the above mentioned post to make it convenient for others who might be searching for same answer).

/**
 * Removes the core 'Menus' panel from the Customizer.
 *
 * @param array $components Core Customizer components list.
 * @return array (Maybe) modified components list.
 */
function wpdocs_remove_nav_menus_panel( $components ) {
    $i = array_search( 'nav_menus', $components );
    if ( false !== $i ) {
        unset( $components[ $i ] );
    }
    return $components;
}
add_filter( 'customize_loaded_components', 'wpdocs_remove_nav_menus_panel' );

It can be done in other ways as well, but they throw a debug error.

Leave a Comment