How to automatically set the first image of a WordPress post as the featured image

This snippet automatically sets the featured image by fetching the first image of the WordPress post.
*Note – if you choose a featured image, that will be displayed instead.

Add this to the functions.php file

Related links: