Disable adding of new post (custom post type)

As per this answer, the “correct way” is:

register_post_type( 'custom_post_type_name', array(
  'capability_type' => 'post',
  'capabilities' => array(
    'create_posts' => false, // Removes support for the "Add New" function ( use 'do_not_allow' instead of false for multisite set ups )
  ),
  'map_meta_cap' => true, // Set to `false`, if users are not allowed to edit/delete existing posts
));

add_action( 'load-post-new.php', 'wpse_58290_disable_new_post' );
function wpse_58290_disable_new_post()
{
    if ( get_current_screen()->post_type == 'my_post_type' )
        wp_die( "You ain't allowed to do that!" );
}

Note that you’ll also need to hide the UI elements, such as in the menu, and the “Add New” button in the h2 tag on the edit screen.

Leave a Comment