Envira Gallery Blog

Digital Photography Tips, Tutorials and Resources

Remove Blog Post Thumbnails

How to Bulk Remove Blog Post Thumbnails in WordPress

by Waseem Abbas on Jul 15, 2016

Do you want to remove multiple blog post thumbnails from your site? Sometimes you may want to remove all your featured images, when redesigning your site for example, and you don’t want to have to remove each one manually. In this article, we will share how to bulk remove blog post thumbnails in WordPress.

Bulk Remove Blog Post Thumbnails

By default, WordPress doesn’t allow you to remove featured images in bulk. However, you may have hundreds of post thumbnails, and it would take an enormous amount of time to remove each of them, one by one.

Thankfully, there is a solution.

This can be done by adding a simple script to your theme files. This script is a database query, and it helps you to remove several blog post thumbnails from your site all at once.

To install the script, simply add the following code to your theme’s functions.php file:

global $wpdb;
$wpdb->query( "
    DELETE FROM $wpdb->postmeta 
    WHERE meta_key = '_thumbnail_id'
" );

After adding the code, make sure to save the document. Now all of your blog post thumbnails will be removed. (However, all of the images you have uploaded will not be deleted, and they will still be in your Media Library.)

Important: make sure to remove this script from your functions.php file immediately after saving it. Otherwise, whenever you add a new featured image in WordPress, this script will keep removing it.

We hope this article has helped you to learn how to bulk remove blog post thumbnails in WordPress. You may also want to check out our guide on how to fix missing post thumbnail issue in WordPress.

If you like this article, then please follow us on Facebook and Twitter for more free WordPress tutorials.

Using WordPress and want to get Envira Gallery free?

Envira Gallery helps photographers create beautiful photo and video galleries in just a few clicks so that they can showcase and sell their work.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.