Last active
September 21, 2022 03:18
-
-
Save wpgaurav/ed9e5f0979e22dc1ac2f1cfcb5d326e4 to your computer and use it in GitHub Desktop.
Batch remove all featured images from your WordPress posts and pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Place the given PHP code in between <?php and ?> inside your theme’s functions.php file. If there is no ending ?> , it is recommended to place the code at the end part of the file. After you finished placing the code, save and update the functions.php file. You will see that all featured images are gone. Now you can remove the above PHP code from functions.php as it is just a one-time job. Please note that you will not be able to set featured images until you remove the mentioned code. (This code will keep removing them.) | |
global $wpdb; $wpdb->query( " DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' " );?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place the given PHP code in between inside your theme’s functions.php file. If there is no ending ?> , it is recommended to place the code at the end part of the file. After you finished placing the code, save and update the functions.php file. You will see that all featured images are gone. Now you can remove the above PHP code from functions.php as it is just a one-time job. Please note that you will not be able to set featured images until you remove the mentioned code. (This code will keep removing them.)