禁用Gutenberg(古腾堡)编辑器,启用老编辑器

自从wordpress5.0之后启用Gutenberg(古腾堡)编辑器,抛弃经典编辑器之后很不习惯.这里介绍无插件改成经典编辑器.

方法一:

  • 屏蔽古藤堡编辑器.(把下面代码放入当前主题functions.php中.)
//禁用古腾堡编辑器
add_filter('use_block_editor_for_post', '__return_false');
//屏蔽古腾堡的样式加载
remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
  • 安装插件Classic Editor.

方法二:

  • 在当前主题functions.php中加入如下代码:
/**
 * WordPress完美禁止使用Gutenberg块编辑器并恢复到经典编辑器
 * WP >= 5.0 正式集成Gutenberg古腾堡编辑器
**/
if ( version_compare( get_bloginfo('version'), '5.0', '>=' ) ) {
    add_filter('use_block_editor_for_post', '__return_false');
// 切换回之前的编辑器
    remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); 
// 禁止前端加载样式文件}
else{    
// 4.9.8 < WP < 5.0 插件形式集成Gutenberg古腾堡编辑器
    add_filter('gutenberg_can_edit_post_type', '__return_false');
}
  • 网上收集的,使用方便.