Fetch the first image from the post

We can grab the first image from the post content using the below function.

Use this code in functions.php of theme and makes sure you have a default image in images folder. So if no image found default image will show up. You can ignore default image if not required.

Leave a Comment