使用ACF pluginFirstly删除自定义设置中所选页面的编辑器
/*
* Add additional settings menu related with ACF plugin
*/
if ( function_exists( \'acf_add_options_page\' ) ) {
acf_add_options_page( array(
\'page_title\' => \'Add. settings of Theme\',
\'menu_title\' => \'Add. settings\',
\'menu_slug\' => \'theme-general-settings\',
\'capability\' => \'edit_posts\',
\'redirect\' => false
) );
下一步是创建与ACF plugin和final中的页面相关的自定义字段
/*
* Remove editor for pages chosen in custom settings, working with ACF plugin
*/
function ogate_remove_editor() {
$pages_without_editor = get_field(\'pages\', \'option\');
if (isset($_GET[\'post\'])) {
$id = $_GET[\'post\'];
$template = get_post_meta($id, \'_wp_page_template\', true);
if(!empty($pages_without_editor)) {
foreach ( $pages_without_editor as $single ) {
$my_template = get_post_meta($single->ID, \'_wp_page_template\', true);
$template == $my_template ?
remove_post_type_support(\'page\', \'editor\') : false;
}
}
}
}
add_action(\'init\', \'ogate_remove_editor\');