Ask any question about WordPress here... and get an instant response.
Post this Question & Answer:
How can I create a custom post type with specific capabilities in WordPress?
Asked on Jan 14, 2026
Answer
Creating a custom post type in WordPress allows you to extend the functionality of your site by adding new content types with specific capabilities. This can be achieved by using the `register_post_type` function in your theme's `functions.php` file or a custom plugin.
<!-- BEGIN COPY / PASTE -->
function my_custom_post_type() {
$args = array(
'label' => 'Books',
'public' => true,
'capability_type' => 'book',
'map_meta_cap' => true,
'capabilities' => array(
'publish_posts' => 'publish_books',
'edit_posts' => 'edit_books',
'edit_others_posts' => 'edit_others_books',
'delete_posts' => 'delete_books',
'delete_others_posts' => 'delete_others_books',
'read_private_posts' => 'read_private_books',
'edit_post' => 'edit_book',
'delete_post' => 'delete_book',
'read_post' => 'read_book',
),
'supports' => array('title', 'editor', 'thumbnail'),
);
register_post_type('book', $args);
}
add_action('init', 'my_custom_post_type');
<!-- END COPY / PASTE -->Additional Comment:
- Replace "book" and "Books" with your desired post type name and label.
- Ensure you define the capabilities in your user roles to manage access properly.
- Consider using a plugin like "User Role Editor" to manage custom capabilities easily.
- Test your custom post type thoroughly to ensure it behaves as expected.
Recommended Links:
