WordPress 技巧:移除特定页面模板下的内容编辑器
2023-06-13 09:18:33 时间
有时候一些特殊模板页面(比如联系我们页面)编辑后台,你可能添加了一些表单之后,想移除默认的编辑器,只需要在当前主题的 functions.php 文件添加下面的代码:
add_action( 'admin_init', 'wpjam_remove_editor' );
function wpjam_remove_editor() {
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
if( !isset( $post_id ) ) return;
$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');
}
}
只需要把上面的 contact.php
替换成你的页面模板即可。
相关文章
- 【学习记录】IDEA编辑器 - 类、方法模板配置
- velocity调用java静态方法_java模板引擎
- 本站同款宁静致远(Quietlee)自媒体博客主题模板,夜间模式及强大的SEO效果-ZBlog主题
- zblog企业展示型主题模板赢天下(Winlee)助力小微企业成长
- zblog分类模板添加自定义排序的教程
- Win32 最简单的窗口模板和常用的5个消息参数使用示例
- emlog pro 模板 API 大字典
- 【Vue3】模板语法
- C++模板(初阶)
- 非类型模板参数/模板的特化/模板的分离编译
- WordPress 主题教程 #4a:Header 模板
- 模板层面向typecho编辑器页面插入代码
- springMVC spring mvc velocity的模板引擎详解编程语言
- ABAP 批导套用模板详解编程语言
- Linux运维工程师简历模板:突出职业能力(linux运维工程师简历模板)
- 利用模板模式优化Redis性能(模板模式设置redis)
- PHP中MVC模式的模板引擎开发经验分享
- thinkphp使用literal防止模板标签被解析的方法
- ThinkPHP跳转页success及error模板实例教程