Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Gutenberg CSS

I have Gutenberg plugin installed in WordPress v4.9.8 and am trying to remove the CSS that comes with it so I can supply my own.

This is the sheet that gets included:

<link rel='stylesheet' id='wp-block-library-css'  href='/wp-content/plugins/gutenberg/build/block-library/style.css?ver=1535795173' type='text/css' media='all' /> 

I have tried the following:

add_action( 'wp_print_styles', 'wps_deregister_styles', 100 ); function wps_deregister_styles() {     wp_dequeue_style( 'wp-block-library-css' );     wp_deregister_style( 'wp-block-library-css' ); } 

As well as variations of this, but the file persists. How can I remove it?

like image 995
Matt Saunders Avatar asked Sep 11 '18 13:09

Matt Saunders


People also ask

How do I uninstall Gutenberg?

Upon activation, you need to visit Settings » Disable Gutenberg page to configure plugin settings. By default, the plugin will disable Gutenberg everywhere for all users on your website. However, if you want to limit it to certain user roles and post types, then you need to uncheck the 'Complete Disable' option.

How do I switch from Gutenberg to classic editor?

Use Both Editors at First – Under Settings>Writing, there is the option to 'allow users to switch editors”. Assuming you have both editors installed, you can turn this option on and ease yourself into the Gutenberg experience by using it alongside the classic editor.


2 Answers

I'm adding this as a more complete answer than my comment:

You need to remove the -css when trying to dequeue the script. That's added to the HTML markup and not the actual tag for the css file.

If you search the code (the location of the enqueue may change as Gutenberg gets rolled into core), you can find:

wp_enqueue_style( 'wp-block-library' ); 

As you can see, there is no -css. This solution may work for other plugins that people have trouble dequeuing styles.

Edit: Since this still gets some traction, here is the code to handle it:

add_action( 'wp_print_styles', 'wps_deregister_styles', 100 ); function wps_deregister_styles() {     wp_dequeue_style( 'wp-block-library' ); } 
like image 113
disinfor Avatar answered Sep 30 '22 06:09

disinfor


I am use this code to to remove default style.

//Disable gutenberg style in Front function wps_deregister_styles() {     wp_dequeue_style( 'wp-block-library' ); } add_action( 'wp_print_styles', 'wps_deregister_styles', 100 ); 
like image 44
Кирилл Меркушев Avatar answered Sep 30 '22 06:09

Кирилл Меркушев