Disable ‘Add New’ in custom post that is made from CPT UI

Thanks Milo. Didn’t consider adding the register_post_type in my functions before because I thought it would interfere with the existing custom post type I made in CPT UI, turns out that it is useful and it override the CPT UI post type.

I used the same slug and it automatically connected the data to the manually created post type. Here’s the code:

function create_post_type() {
register_post_type( 'office_post', 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 )
  ), 
  'labels' => array(
    'name' => __( 'Office' ),
    'singular_name' => __( 'Office' )
  ),
  'map_meta_cap' => true, // Set to `false`, if users are not allowed to edit/delete existing posts
  'public' => true,
  'menu_icon' => 'http://architecture.com/testdrive/wp-content/uploads/2018/04/logo-white-e1524992076968.png',
));
} 
add_action( 'init', 'create_post_type' );