When you decide to change your theme or use another way of displaying an image for your posts, you find yourself tied up with the featured images you added to each post in the past
By default, featured images can only be removed by editing each post and removing the featured image attached. If you have hundreds of posts that use featured images, removing all of them one by one becomes a huge time consuming task. Instead, you can run a database query and unset (not remove) the featured images on all posts.
The code below will remove the featured image from all posts (including custom post types) in your WordPress website but it will not delete any of your uploaded images, images still being available in Media Library for later use with an auto post thumbnail plugin.
Copy – paste this code in the theme’s functions.php file.
global $wpdb;
$wpdb->query( ”
DELETE FROM $wpdb->postmeta
WHERE meta_key = ‘_thumbnail_id’
” );
When you save the edited functions.php file, the script will run a database query and remove featured images from all posts. After saving the functions.php file, remove this code because it will also prevent you from setting featured images in WordPress by constantly removing them.