Require a featured image to WordPress posts
If you own a multi-author Wordpress blog or website and you want to force a required featured image for all your posts then the script below is all that you need. Adding this snippet to your functions.php will make sure that all your posts have a featured image before they are published.
Basically, the snippet is a PHP function wrapped in a WordPress action. When you hit the publish button it checks if the author has associated a featured image to his post. If no featured image has been assigned to the post, the function displays an error message to the user and advises him to add one in order for the post to be published.
Please note that this snippet can be used to require a featured image for pages and for custom post types as well.
For example, if you have a custom post type named ‘book’ and you wish to force the use of a featured image for it then just update the third line in the snippet as follows: