我希望这个标题有意义。我当前想在某些页面上隐藏默认的所见即所得编辑器,但在其他页面上显示它。
函数文件是否有过滤器或挂钩?
我希望这个标题有意义。我当前想在某些页面上隐藏默认的所见即所得编辑器,但在其他页面上显示它。
函数文件是否有过滤器或挂钩?
我希望我正确理解了你的问题。
以下代码将使用特定模板从页面中删除编辑器:
<?php
function wpse242371_remove_editor_from_some_pages()
{
global $post;
if( ! is_a($post, \'WP_Post\') ) {
return;
}
/* basename is used for templates that are in the subdirectory of the theme */
$current_page_template_slug = basename( get_page_template_slug($post_id) );
/* file names of templates to remove the editor on */
$excluded_template_slugs = array(
\'tmp_file_one.php\',
\'tmp_file_two.php\',
\'tmp_file_three.php\'
);
if( in_array($current_page_template_slug, $excluded_template_slugs) ) {
/* remove editor from pages */
remove_post_type_support(\'page\', \'editor\');
/* if needed, add posts or CPTs to remove the editor on */
// remove_post_type_support(\'post\', \'editor\');
// remove_post_type_support(\'movies\', \'editor\');
}
}
add_action(\'admin_enqueue_scripts\', \'wpse242371_remove_editor_from_some_pages\');
remove_post_type_support( \'page\', \'editor\' );
您可以通过多种方式使用它,在页面中设置一个复选框会很好,如果选中该复选框,将隐藏编辑器。有关更多信息>https://codex.wordpress.org/Function_Reference/remove_post_type_support
我想知道我是否在函数中添加了一些短代码。php在我的主题和解决我的问题,会发生什么,如果我更新我的主题??更新后是否删除我的短代码??在将代码添加到函数后,更新主题是否会有任何问题。php?