I have a CPT "foo". I want to totally disable the "trash can" feature, so that any time on the the CPTs is deleted, it is simply permanently removed. Not put in the trash can. How can I do this programatically?

1 Answer 1


If you wanted to do this for all post types, you'd simply do

define('EMPTY_TRASH_DAYS', 0);

see https://codex.wordpress.org/Trash_status#EMPTY_TRASH_DAYS_option.

But since you only want to do this for a custom post type, you will need to hook into 'trashed_post' like this:

add_action('trashed_post', function( $post_id ){ 

then check your trashed posts' post type:

    if ( get_post_type($post_id) === 'foo') {

and use wp_delete_post() with the 'force delete' parameter set to true on posts that turn out to be of your targeted post type:

        wp_delete_post( $post_id, true );

I'd guess WordPress will then probably still show the 'moved into trash bin' message, even though it'll appear to the user as if there was no trash bin and the post will indeed already be deleted entirely. So you might have to change the $labels that are passed to your register_post_type() call if that's the case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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