Utilising WordPress Excerpts is a great way to create a short summary about a prospective Blog Post, which can lend to the creation of an overall ‘newspaper’ style blog homepage that provides links to the dedicated-page for each individual blog post on your website design.
If you’re already familiar with WordPress Excerpts, by default you’ll know that there is no method to add an image to an excerpt (which we’ve covered before) or to take things one-step further, the option to automatically pull an image from a Blog Post to a WordPress Excerpt.
After having to solve this issue for myself recently, I came across a handy WordPress Plugin that I thought was worth sharing called Simple Image Grabber.
How to Automatically Add an Image to a WordPress Excerpt
Simple Image Grabber is designed to do exactly what it says on the tin, automatically grab a designated image from a WordPress Blog Post and stick it in an excerpt using a designated piece of code.

Download & Install the 'Simple Image Grabber Plugin'
Firstly, you’ll need to install the Plugin which can be found right here and then upload the files within to the wp-content/plugins folder of your Blog as per usual. Once complete, navigate to the WordPress Plugins section of your Blog and activate the Plugin.
Now, the slightly trickier part, getting the images to appear. First, open up the WordPress template files that you wish to use the Plugin for, which presumably will be the index.php and archive.php templates.
Now, you’ll need to stick in a variation of the following code within the post loop
<?php images($number, $width, $height, $class, $link); ?>
$number defines which number image you wish to pull from your blog post, $width and $height represent the width and height of the image in pixels, $class can be replaced with a CSS class if necessary and $link will auto-generate a link to the blog post by stating ‘true/false’.
For example, if you wish to pull the first image from your blog post, giving it a 300px width and 600px height, but no post-link or CSS class, you’d use the following snippet of code in the loop (e.g. just above an ‘the_excerpt()’ statement):
<?php images('1', '300', '600', '', true); ?>
Once edited to your liking, reupload your templates and it’ll (hopefully) work like magic. Quick Tip: You can also leave the $width and $height variables empty if you want the images to remain their default size in pixels.
Further Reading
We’ve published many blog posts and video blogs in the past covering containing other WordPress Tutorials including How to Use Custom-Post Types, using Multiple Loops and Installing WordPress on a Root-Layer.
