发布时间:2020-09-17
WordPress 技巧:移除特定页面模板下的内容编辑器,
有时候一些特殊模板页面(比如联系我们页面)编辑后台,你可能添加了一些表单之后,想移除默认的编辑器,只需要在当前主题的 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
替换成你的页面模板即可。
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
本站推荐使用的主机:,国外主机建议使用。
全站搜索