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'.. :)
UPDATE
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;
}