WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I disable adding of new posts of a particular custom post type?

Found this code in Log Deprecated Notices plugin:

    $screen = get_current_screen();
    if ( self::pt == $screen->id && ( $screen->action == 'add' || $_GET['action'] == 'edit' ) )
        wp_die( __( 'Invalid post type.', 'log-deprecated' ) );
    if ( self::pt != $screen->post_type )
share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
Thanks, would you hide those just via CSS? – drtanz Jul 12 '12 at 15:28
You might be better off removing the menu item by hooking onto admin_menu and searching for/unsetting the item in the global $submenu. As for the other items, check out the source & see if there's any suitable hooks/filters, otherwise fallback to CSS/JS. – TheDeadMedic Jul 12 '12 at 15:43
Also how can I remove the Edit and Quick edit links – drtanz Jul 12 '12 at 15:49
I don't have a menu item as I am adding the cpt to the menu via add_submenu_page – drtanz Jul 12 '12 at 15:50

As an addition to the above/accepted answer, you could use this function to hide the actual links to the pages you want to disable.

share|improve this answer
Please explain why that could solve the problem. – toscho Mar 16 '13 at 22:42
It is part of the solution. the answer of TheDeadMedic make sure they won't be able to visit the add and edit page, this piece will the items from the admin menu. In this case, custom post type product – Frankey Nov 17 '14 at 11:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.