How To Remove Featured Images Globally From Posts in WordPress
Remove Featured Images Globally From Posts – Just one of our readers requested us how they can be unpackaged remove featured images from posts in WordPress? At TutsFx, we have conferred featured images (post thumbnails) several times. We displayed you how to add featured images in WordPress, how to add new image dimensions in WordPress, how to regenerate thumbnails, we even showed you how to add several featured images to a post in WordPress. In this article, we will show you how to remove featured images globally from posts in WordPress.
The Issue With Bulk Removal of Post Thumbnails or Featured Images in WordPress
Unfortunately, by default, you can only remove featured images by editing separately post and removing the featured image. Now if a user has hundreds plus of posts with featured images, then removing them 1 by 1 can be a very time-consuming job. Instead, we are going to try a different approach. We will run a database query and unset the featured images on all posts.
Before you continue, please note that the code below will remove featured images from all posts on your WordPress site by just pasting. Also, note that this code will not remove any of your uploaded images, they will still be available in Media Library and you can reuse them anytime.
All you need to do is copy and paste this code in your theme’s
global $wpdb; $wpdb->query( " DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' " );
That’s all. As soon as you save your functions.php file this script will run a database query and remove featured images from all posts.
Important: Please remove this code immediately after saving your functions.php file. You will not be able to set featured images in WordPress as this code will keep removing featured images from posts.