WordPress 5.0正式版发布以后,新的Gutenberg 编辑器给众多用户带来困惑,很多用户都在寻找切换回以前经典编辑器的方法。
可以通过安装Classic Editor或者Disable Gutenberg插件,切换回经典的编辑器。
这里快男向你推荐无插件的方法。
其实之前经典的Classic Editor编辑器代码,在WordPress 5.0并没有被删除,上述插件也只是个切换开关而已。
关键代码就一句:
add_filter('use_block_editor_for_post', '__return_false');
后台禁用block editor编辑器后,前端还是会加载相关的的样式文件,需要加上一句:
remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
所以最后的代码是:
//禁止 WordPress5.0 使用 Gutenberg 块编辑器 add_filter('use_block_editor_for_post', '__return_false'); remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );