In WordPress, most people will notice an “Additional CSS” section in the customizer when they update. This is an awesome feature and a perfect use of the customizer. It”ll be great for the vast numbers of users who just need to add some basic CSS to customize their theme.
However, for many of us, it’s an unwanted feature on our own sites for one reason or another. so let’s see how to Remove Additional CSS from the WordPress Customizer.
So Add this code in your theme’s functions.php file of your active child theme (or theme) and Save the file.
This code will remove completely the Additional CSS section from your WordPress site.
function customizer_remove_css_section( $wp_customize ) { $wp_customize->remove_section( 'custom_css' ); } add_action( 'customize_register', 'customizer_remove_css_section', 15 );
Remove the Additional CSS Conditionally
What if you want to remove it for everyone except administrators? In that case you’d need to check the user role too, and you can do it so. This code will remove the section for everyone who can’t manage_options, so everyone who is not Admin or Super Admin.
function customizer_remove_css_section( $wp_customize ) { $user = wp_get_current_user(); if ( ! $user->has_cap( 'manage_options' ) ) { $wp_customize->remove_section( 'custom_css' ); } } add_action( 'customize_register', 'customizer_remove_css_section', 15 );
Remove the Additional CSS for specific users based on their ID:
This code will remove the Additional CSS from any user that is not ID 1, which usually is the first user created when creating the WordPress site.
function customizer_remove_css_section( $wp_customize ) { $user = wp_get_current_user(); if ( $user->ID !== 1 ) { $wp_customize->remove_section( 'custom_css' ); } } add_action( 'customize_register', 'customizer_remove_css_section', 15 );