How To Bulk Remove All Featured Images In WordPress?

Most WordPress themes displays the featured images when they are set on content editing screen and hides when the user unset the featured image i.e. post thumbnail.

The problem comes when you like removing the featured images sitewide in WordPress, default WordPress functionality allows you to remove featured images one by one i.e. on per post basis which takes a lot of time and the solution is ofcourse not for the bloggers having thousands of posts. Editing the code for removing post thumbnail display is a better option in such cases.

Here’s a solution if you like to easily remove all featured images from your website. All you have to do is open your theme’s function.php file and add the following code:

global $wpdb;
$wpdb->query( “
DELETE FROM $wpdb->postmeta
WHERE meta_key = ‘_thumbnail_id’
” );

Save the changes and the code will run a query removing all featured images from all posts, pages and post types of your WordPress site.

Later on, you can either remove the code from your theme’s functions file or leave it there if you don’t want to see featured images ever in your website.

Note that if you leave the code in your theme then you will not be able to set featured images again as the code will keep removing all set featured automatically.

The code can also be used via Code Snippets plugin, it provide you a post type interface for adding, activating and managing custom hacks in WordPress.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.