# Bulk Remove Featured Images

> Adds a "Remove featured image" bulk action to post and page lists that clears the featured image from all selected items at once, without deleting the images from the Media Library.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: bulk-actions, featured-image, posts
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/admin-bulk-remove-featured-image/

## Code

```php
foreach ( array( 'post', 'page' ) as $wpide_type ) {
    add_filter( "bulk_actions-edit-{$wpide_type}", function ( $actions ) {
        $actions['wpide_remove_thumbnail'] = 'Remove featured image';
        return $actions;
    } );

    add_filter( "handle_bulk_actions-edit-{$wpide_type}", function ( $redirect, $action, $post_ids ) {
        if ( 'wpide_remove_thumbnail' !== $action ) {
            return $redirect;
        }
        $done = 0;
        foreach ( $post_ids as $post_id ) {
            if ( current_user_can( 'edit_post', $post_id ) && delete_post_thumbnail( $post_id ) ) {
                $done++;
            }
        }
        return add_query_arg( 'wpide_thumbs_removed', $done, $redirect );
    }, 10, 3 );
}

add_action( 'admin_notices', function () {
    if ( isset( $_GET['wpide_thumbs_removed'] ) ) {
        printf( '<div class="notice notice-success is-dismissible"><p>Removed the featured image from %d items.</p></div>', absint( $_GET['wpide_thumbs_removed'] ) );
    }
} );
```

## Notes

The images stay in the Media Library and can be set again at any time.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Bulk Remove Featured Images" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
