隐藏带有“自定义帖子类型”的内容框?


18

我创建了一个自定义帖子类型,我想在发布/编辑页面中隐藏主要的textarea内容。

可能吗 ?

谢谢!

Answers:


33

是的,从您的自定义帖子类型中删除编辑器支持。

您可以通过两种方式来实现。

  1. 在注册您的自定义帖子类型时:

例:

$args = array(
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'capability_type' => 'post',
    'has_archive' => true, 
    'supports' => array('title','author','thumbnail','excerpt','comments')
); 
register_post_type('book',$args);

2.如果您的代码未定义自定义帖子类型,则使用remove_post_type支持(即其他一些插件/主题定义了自定义帖子类型)。

例:

add_action('init', 'my_rem_editor_from_post_type');
function my_rem_editor_from_post_type() {
    remove_post_type_support( <POST TYPE>, 'editor' );
}

您可以使用媒体管理器上传文件,也可以构建自己的自定义元框来处理上传。
Hameedullah Khan 2011年

12

注册自定义帖子类型时,请不要指定对编辑器的支持。

 $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    // on the supports param here you see no 'editor'
    'supports' => array('title','author','thumbnail','excerpt','comments') 
  ); 
  register_post_type('book',$args);

更多信息,请参见:功能参考/注册职位类型



0

您可以在帖子模块的管理员中删除标题或编辑器

function mvandemar_remove_post_type_support() {
    remove_post_type_support( 'post', 'title' );
    remove_post_type_support( 'post', 'editor' );
}
add_action( 'init', 'mvandemar_remove_post_type_support' );
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.