是的,您可以通过删除来禁用默认编辑器\'editor\' 来自register\\u post\\u类型(\'product\',$args)的supports属性数组
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'comments\', \'custom-fields\' ),
把这个换成这样的东西
\'supports\' => array( \'title\', \'thumbnail\', \'comments\', \'custom-fields\' ),
您可以阅读wordpress函数参考
register_post_type 了解有关自定义post类型参数的详细信息。
Update:
Method 1:
要更改register\\u post\\u type args,请通过“
register_post_type_args“过滤器挂钩。
add_filter( \'register_post_type_args\', \'product_support_args\', 10, 2 );
function product_support_args( $args, $post_type ){
$post_ids_array = array(2119, 2050); // Add Your Allowed Post IDs Here
if ( \'product\' === $post_type && is_admin()){
$post_id = $_GET[\'post\']; // Get Post ID from URL
// Check if the post ID is whitelisted
if(in_array($post_id, $post_ids_array)){
$args[\'supports\'] = array( \'title\', \'thumbnail\', \'comments\', \'custom-fields\' ); // Remove Editor from supports args array
}
}
return $args;
}
Method 2:
通过使用
remove_post_type_support() 作用如果需要,您可以按照上面的方法传递允许的post ID数组。
add_action( \'current_screen\', \'remove_editor_support\' );
function remove_editor_support() {
$get_screen = get_current_screen();
$current_screen = $get_screen->post_type;
$post_type = \'product\'; // change post type here
if ($current_screen == $post_type ) {
remove_post_type_support( $current_screen, \'editor\' ); // remove editor from support argument
}
}