Sometimes, you do not want the Additional CSS option to appear on the WordPress Customizer when you are not willing to change the styling of your website. In that case, you can Remove the Additional CSS from the WordPress Customizer option to make sure that no one will add additional styles to your website.
Additional CSS is stored in the database, within the wp_posts table, under the custom_css post type, where the post name is the theme slug. There you also have the related customize_changeset and revision post types.
There are Four techniques for adding custom CSS to WordPress:
-
- Using the Customizer
- With a plugin
- Editing the style.css file of your child theme
- Editing the functions.php file of your child theme
Write the following code in your functions.php file to Remove Additional CSS from the WordPress Customizer.
-
- Login to your WordPress Admin Dashboard.
- Now from the left sidebar go to Appearance -> Theme Editor.
- Go to functions.php file and write below code.
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 for specific users based on their ID
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 );
Here are a few examples covering the best CSS tutorials for beginners. W3Schools CSS Tutorial | Codeacademy Learn CSS
To Continue Learning, you can refer our blogpost Hide the Product Price When Price Zero
Thank you for taking the time to read our blog. We are confident that you have found our ideas and processes to be of great value. Erudite Works Private Limited is a leading IT consulting firm, with a strong focus on delivering exceptional results. Our team of experts is fully dedicated to understanding the unique needs and challenges of our clients, allowing us to provide tailored solutions that drive significant business growth. With a proven track record of successful projects, we are committed to assisting our clients in achieving their goals and maintaining a competitive edge in today’s rapidly evolving digital landscape. If you would like to learn more about our services, please feel free to Contact Us.
This website has got a lot of extremely useful info on it! Thanks for sharing it with me!
XMC.pl – Thank you so much for the positive review.
The following time I read a weblog, I hope that it doesnt disappoint me as a lot as this one. I mean, I know it was my option to learn, but I actually thought youd have one thing interesting to say. All I hear is a bunch of whining about something that you could possibly fix if you happen to werent too busy searching for attention.
Blogi – Thank you so much for taking the time to provide feedback.
Blogi – Thank you so much for taking the time to provide feedback.