Andy Tran

Remove Additional CSS from the WordPress Customizer

by | 27 Aug, 2021 | Wordpress | 5 comments

Remove additional CSS wp

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


Remove Additional CSS from WordPress Customizer

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

Share this article...

5 Comments

  1. XMC.pl

    This website has got a lot of extremely useful info on it! Thanks for sharing it with me!

    Reply
    • Palak Mistry

      XMC.pl – Thank you so much for the positive review.

      Reply
  2. Blogi

    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.

    Reply
    • Palak Mistry

      Blogi – Thank you so much for taking the time to provide feedback.

      Reply
  3. Palak Mistry

    Blogi – Thank you so much for taking the time to provide feedback.

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.