0

I need to disable 'Add New' button for my CPT, but when I add:

'capabilities' => array(
    'create_posts' => false,
    'edit_posts' => true,
    'edit_post' => true,
    'delete_post' => true,
),

I can only VIEW this post (I can't edit and delete it) - why?

1

Full credit to this answer on Stack Overflow: you need to set the create_posts value to do_not_allow (or false in Wordpress versions below 4.5) and crucially set the map_meta_cap to 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
));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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