I would really appreciate some help here. I have created custom post types and mapped capabilities. The custom post types show up in the admin panel, but I can’t add a new post. When I remove capabilities=> $capabilities and change it to capability_type => ‘post’ it starts working.
// 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')
);
I imagine that I have made a simple mistake, but I can’t figure it out. Could someone please have a look over the code and let me know what I have done wrong, please? I am pulling my hair out over here.
Adding new capabilities for custom post types not enough. You must to add same capabilities to a builtin role or specific user or create new role with new capabilities. You can read more info in Codex User_and_Author_Functions.