自定义帖子类型功能

时间:2014-10-04 02:39:50

标签: wordpress custom-post-type capability

我真的很感激这里的一些帮助。我创建了自定义帖子类型和映射功能。自定义帖子类型显示在管理面板中,但我无法添加新帖子。当我删除capabilities => $ capabilities并将其更改为capability_type => '发布'它开始工作。

// Human Sciences posts

    $capabilities = array(
     'publish_posts'        => 'publish_human',
     'edit_posts'           => 'edit_humans',
     'edit_others_posts'    => 'edit_others_human',
     'delete_posts'         => 'delete_human',
     'delete_others_posts'  => 'delete_others_human',
     'read_private_posts'   => 'read_private_human',
     'edit_post'            => 'edit_human',
     'delete_post'          => 'delete_human',
     'read_post'            => 'read_human',

);

$labels = array(
    'name'                  => 'Human Sciences Post',
    'singular_name'         => 'Post',
    'menu_name'             => 'Human Sciences Posts',
    'name_admin_bar'        => 'Human Sciences',
    'add_new'               => 'Add New',
    'add_new_item'          => 'Add New Post',
    'new_item'              => 'New Human Sciences Post',
    'edit_item'             => 'Edit Post',
    'view_item'             => 'View Posts',
    'all_items'             => 'All Human Sciences Posts',
    'search_items'          => 'Search Human Sciences Posts',
    'parent_item_colon'     => 'Parent Posts',
    'not_found'             => 'No Post Found',
    'not_found_in_trash'    => 'No Post Found in Trash',

);

$args = array(
    'labels'                => $labels,
    'public'                => true, 
    'publicly_queryable'    => true,
    'show_ui'               => true,
    'show_in_menu'          => true,
    'menu_position'         => 6,
    'menu_icon'             => 'dashicons-visibility',
    'query_var'             => true,
    'rewrite'               => array( 'slug' => 'human-science' ),
    'capabilities'          => $capabilities,
    'has_archive'           => true,
    'hierarchical'          => true,
    'supports'              => array( 'title', 'editor', 'thumbnail', 'comments', 'post_formats' ),
    'taxonomies'            => array( 'category', 'post_tag')
);

我想我犯了一个简单的错误,但我无法弄清楚。有人可以看看代码,让我知道我做错了什么,拜托?我把头发拉到这里。

1 个答案:

答案 0 :(得分:0)

为自定义帖子类型添加新功能还不够。您必须向内置角色或特定用户添加相同的功能,或者使用新功能创建新角色。您可以在Codex User_and_Author_Functions中阅读更多信息。

相关问题