吾上云WORDPRESS教程最新“如何隐藏WordPress指定页面模板的可视化编辑器呢?”
当我们添加一些元数据到WordPress 中的某个页面的时候,WordPress 默认的编辑器可能就用不上了。为了提高用户的编辑体验,把这些页面的可视化编辑器隐藏掉是一个比较直接的办法。那么如何隐藏WordPress指定页面模板的可视化编辑器呢?
直接把下面的代码复制到主题的 functions.php 中就可以了。复制之前,需要先替换下面代码中的contact.php
为你所用主题的页面模板名称。比如,我在主题中定义了一个模板叫page-noediter
,就需要把contact.php
替换为page-noediter
。
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
// Get the Post ID.
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
if( !isset( $post_id ) ) return;
// Get the name of the Page Template file.
$template_file = get_post_meta($post_id, '_wp_page_template', true);
if($template_file == 'contact.php'){ // edit the template name
remove_post_type_support('page', 'editor');
}
}
文章来源于互联网WORDPRESS教程:如何隐藏WordPress指定页面模板的可视化编辑器呢?,
阿里云服务器89元起,点击购买
腾讯云服务器95元/年起 点击购买
吾上云WORDPRESS教程最新“IT运维常见问题之一:服务器内存占有率高”登录服务器一看,服务器也很卡,打开任务管理器,一看内存占有率99%了,在仔细一查看是“数据库占用了大量内存”,打开数据库一看是部署的时候没有对数据库实例设置“最大服务器内存”,下面就分…
评论前必须登录!
注册