全额贷记至this answer 堆栈溢出:您需要设置create_posts
值到do_not_allow
(或false
在4.5以下的Wordpress版本中),并将map_meta_cap
到true
:
register_post_type( \'custom_post_type_name\', array(
\'capability_type\' => \'post\',
\'capabilities\' => array(
\'create_posts\' => \'do_not_allow\', // Prior to Wordpress 4.5, this was false
),
\'map_meta_cap\' => true, // With this set to true, users will still be able to edit & delete posts
));