Add custom post notice after post delete

Checking the bulk counts

We can check the bulk counts, to see if any post was deleted:

add_filter( 'bulk_post_updated_messages', function( $bulk_messages, $bulk_counts )
{
    // Check the bulk counts for 'deleted' and add notice if it's gt 0
    if( isset( $bulk_counts['deleted'] ) && $bulk_counts['deleted'] > 0 )
        add_filter( 'admin_notices', 'wpse_243594_notice' );

    return $bulk_messages;
}, 10, 2 );

where we define the callback with our custom notice as:

function wpse_243594_notice()
{
    printf( 
        '<div class="notice notice-info is-dismissible">%s</div>',
        esc_html__( 'Hello World!', 'domain' )
    );
}

The bulk counts contains further info for updated, locked, trashed and untrashed.

Output example

custom notice on post delete

Hope you can adjust this further to your needs!

Leave a Comment

techhipbettruvabetnorabahisbahis forumueduedusedueduseduseduseduseduseduedus