How to Set the First Image in a WordPress Post to the Featured Image (Even for Old Posts / No Programming Required)

I found this nifty plugin which will auto-set the first image of a WordPress post as your featured image.

Unfortunately, it only does it for new posts. Or so the plugin says, rather, it only does it when you update a post in some way. I suppose that’s cool for blogs where authors don’t remember to set the featured image, but I needed to go back through 1800 posts and do this all programmatically.

So I found an interesting workaround.

Firstly, install the aforementioned plugin.

Next, create a new category for your posts, something like “Test” or “Featured Image Fixer”.

Now, into your WordPress Posts area (where it lists all of your posts) and click the Screen Options button.

screen shot showing how to get the screen options area in WordPress post editor
Click Screen Options, then set the number to something high.

Now, set Number of items per page to something high. How high you set this will depend on how great your server is (set it too high on a crappy shared server and you’ll just time out, set it too low and you’ll add more work for yourself). On an awesome WP Engine server I was able to set it to 300 and run through the following with no problems.

Once you’ve got it set relatively high, click the check box just beneath Bulk Actions. This will select all of the posts shown on that page.

screen shot showing checkboxes referred to in post
Check those boxes, boys.

Now from the Bulk Actions dropdown, choose Edit and then Apply. This will give you an interface where you can add all of these posts to our new “Test” (or whatever you called it) category. Don’t check any other boxes! The original categories will be preserved, and only the new “Test” category will be applied. We’ll be getting rid of that later.

Click Update and the necessary processes (ie, WordPress save_post action) will be applied. This is all the plugin needs to have happen in order to do its magic, and now all of these posts will get their featured image updated.

Click through the pagination until you’ve done this enough times to run through all of your posts, and you’re golden. Deactivate the plugin when you’re done, unless you like its default functionality, too.

Up Next: How to Automatically Create WordPress Navigation Menu Items