So I have a custom post type called members. linked with advanced custom fields and I've made it so if I delete a member from the custom post type it doesn't move to the trash and permanently deletes it. but I still get this message:

enter image description here

the line I'm trying to override inside /wp-admin/edit.php is:

'trashed'   => _n( '%s post moved to the Trash.', '%s posts moved to the Trash.', $bulk_counts['trashed'] ),

the code I've tried inside functions.php to change it is as follows:

add_filter( 'post_trashed_messages', function( $messages )
    $messages['post'][2] = 'Succesfully deleted';
    return $messages;
} );

1 Answer 1


There's no hook named post_trashed_messages, but there is the bulk_post_updated_messages hook which you can use to change the bulk action updated messages:

add_filter( 'bulk_post_updated_messages', function ( $bulk_messages, $bulk_counts ) {
    $bulk_messages['post']['trashed'] = _n( '%s post successfully deleted.', '%s posts successfully deleted.', $bulk_counts['trashed'] );
    return $bulk_messages;
}, 10, 2 );

Or to target a specific post type, set the key to the post type slug ($bulk_messages['<post type slug>']) — in the example below, the post type slug is my_cpt:

add_filter( 'bulk_post_updated_messages', function ( $bulk_messages, $bulk_counts ) {
    $bulk_messages['my_cpt'] = isset( $bulk_messages['my_cpt'] ) ? $bulk_messages['my_cpt'] : array();
    $bulk_messages['my_cpt']['trashed'] = _n( '%s post successfully deleted.', '%s posts successfully deleted.', $bulk_counts['trashed'] );
    return $bulk_messages;
}, 10, 2 );

Also, as you could see above, I suggest you to let users (and/or yourself) know how many posts were deleted. So make use of the $bulk_counts['trashed'] instead of simply saying 'Successfully deleted'.. :)


In reply to your comment, "how to get rid of the undo button", I don't see a filter for that, but you can use CSS to visually hide the button: (Just change the my_cpt to the correct (post type) slug.)

body.edit-php.post-type-my_cpt #message a[href*="&doaction=undo&action=untrash"] {
    display: none;
  • this changed the message as I wanted it to. But would u also happen to know how to get rid of the undo button?
    – Asta
    Mar 4, 2020 at 14:20
  • Answer updated. You can also use CSS in combination with JavaScript to completely remove the button (from the DOM), but you'll need to try doing that on your own.. Alternatively, you could add a custom link to the list and add your own message for that link without the "undo" button. That requires more coding, though.
    – Sally CJ
    Mar 4, 2020 at 14:55

Your Answer

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

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