WordPresss使用代码完美禁止使用Gutenberg块编辑器并恢复到经典编辑器

其实之前经典的 Classic Editor 编辑器代码,在 WordPress5.0 并没有被删除,上述插件也只是个切换开关而已。另据 WP 官方称,Classic Editor 编辑器代码会延续集成到 2021 年才会从程序中彻底删除,但大家也不用担心,到时会有全套的 Classic Editor 编辑器插件让你选择。

将下面的代码添加到当前主题函数模板 functions.php 中即可,根本不需要那些插件,即可完美的禁止 Gutenberg 编辑器并恢复到熟悉的经典编辑器(并可兼容判断 WP 的版本)。当然如果你是VIEU主题那就放在functions-theme.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');
}

主题新建页面链接可设置后辍为.html代码

很多人喜欢把wordpress博客伪静态展现,文章伪静态规则设定好后台设置的固定链接设置好就好了… 唯独新建的页面上没有带.html
如今找到了一个方法让页面链接也是.html结尾后缀
首先在主题目录下functions.php添加以下代码,然后后台设置里的固定链接更新下就好了,当然如果你是VIEU主题那就放在functions-theme.php

add_action('init', 'html_page_permalink', -1);

function html_page_permalink() {

global $wp_rewrite;

if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){

$wp\_rewrite->page\_structure = $wp_rewrite->page_structure . '.html';

}

}

Last modification:February 9th, 2019 at 02:48 pm
If you think my article is useful to you, please feel free to appreciate