Mat*_*ers 22 css wordpress wordpress-gutenberg
我在WordPress v4.9.8中安装了Gutenberg插件,我正在尝试删除随附的CSS,以便我可以自己提供.
这是包含的表格:
__CODE__
我尝试过以下方法:
<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' />
Run Code Online (Sandbox Code Playgroud)
除了这个的变化,但文件仍然存在.我该如何删除它?
dis*_*for 28
我将此添加为比我的评论更完整的答案:
-css在尝试使脚本出列时,您需要删除它.这已添加到HTML标记中,而不是css文件的实际标记.
如果你搜索代码(当Gutenberg进入核心时,enqueue的位置可能会改变),你可以找到:
-css
如你所见,没有-css.此解决方案可能适用于人们出现问题的其他插件.
小智 13
我使用此代码来删除默认样式.
//Disable gutenberg style in Front
function wps_deregister_styles() {
wp_dequeue_style( 'wp-block-library' );
}
add_action( 'wp_print_styles', 'wps_deregister_styles', 100 );
Run Code Online (Sandbox Code Playgroud)
我使用的是Wordpress 5.1。尝试了最受好评的答案,但它们对我没有帮助,'wp_enqueue_scripts'而不是'wp_print_styles'窍门。
这是我的整个WordPress 5.1解决方案,可消除没有膨胀的样式表加载的Gutenberg:
// Disable Gutenberg editor.
add_filter('use_block_editor_for_post_type', '__return_false', 10);
// Don't load Gutenberg-related stylesheets.
add_action( 'wp_enqueue_scripts', 'remove_block_css', 100 );
function remove_block_css() {
wp_dequeue_style( 'wp-block-library' ); // Wordpress core
wp_dequeue_style( 'wp-block-library-theme' ); // Wordpress core
wp_dequeue_style( 'wc-block-style' ); // WooCommerce
wp_dequeue_style( 'storefront-gutenberg-blocks' ); // Storefront theme
}
Run Code Online (Sandbox Code Playgroud)
编辑:
它也可以与WordPress 5.2一起使用,并且由于它可以处理WooCommerce和Storefront主题添加的样式表,因此我将其设置为新插件中的一项:
https://wordpress.org/plugins/extra-settings-for-woocommerce/