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
));
WordPress Networks: 我发现 Seamus Leahy 的回答不起作用如果你是作为网络的超级管理员登录的,那么当 CMS 调用 current _ user _ can ($cap)时,用户是否具备这个功能并不重要。通过挖掘核心,我发现你可以做到以下几点。
register_post_type( 'custom_post_type_name', array(
'capability_type' => 'post',
'capabilities' => array(
'create_posts' => 'do_not_allow', // Removes support for the "Add New" function, including Super Admin's
),
'map_meta_cap' => true, // Set to false, if users are not allowed to edit/delete existing posts
));