iThemes site-wide discount! 40% OFF Grab this offer!

How to Add Auto Featured Image on WordPress? Step By Step Guide

Adding a custom-designed extra image as a featured image in a blog post is a boring task if you are a busy blogger. It’s more boring when you do the same task in every post. 

That’s why now most WordPress popular themes have a feature to add a featured image automatically above/below the default post title even in the post archive section from the 1st image of the post article. 

However, if your existing theme doesn’t support 1st image from the post article as a featured image or don’t want to add the featured image manually from your WordPress media library, you can add a snippet of code to your theme file.

So that when you publish a blog post, the theme will automatically add a featured image in the post. Don’t worry you have an alternate option. You can use an auto featured post plugin instead of manually adding a snippet of code in your theme’s file.

auto featured image

In this post, I will step by step guide you on how to add automatically a featured image in a post from the first image of the post’s article by adding a simple snippet of code or using an auto featured image plugin.

Let’s get started

Set The First Post Image as Featured Image on WordPress Using Code

I always recommend using code instead of a plugin to add or run features on the WordPress site. Adding more plugins can cause slow website loading, so always try to use code if you have one.

But if you have no little coding knowledge, don’t try. Because your unaware activity may break your site so that you may lose everything if you have no backup. 

So before trying manually, take a backup of your site using a backup plugin. I use BackupBuddy which is a premium plugin of iThemes. But you can use Updraft plus as well. 

Instruction: Firstly add the following code to your theme’s funcation.php file to automatically set the featured image for your post article. If you manually add a featured post thumble, then it will override this code and display your featured post image instated automatically generated featured image from the first image of the article.

function autoset_featured() {
    global $post;
    $already_has_thumb = has_post_thumbnail($post->ID);
        if (!$already_has_thumb)  {
        $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
            if ($attached_image) {
                foreach ($attached_image as $attachment_id => $attachment) {
                    set_post_thumbnail($post->ID, $attachment_id);
                }
            }
        }
}
add_action('the_post', 'autoset_featured');
add_action('save_post', 'autoset_featured');
add_action('draft_to_publish', 'autoset_featured');
add_action('new_to_publish', 'autoset_featured');
add_action('pending_to_publish', 'autoset_featured');
add_action('future_to_publish', 'autoset_featured');

Set Featured Image Using a Plugin

There are lots of plugins for showing a featured image, but here I will recommend using Auto Featured Image (Auto Post Thumbnail) which is the best rating plugin in the WordPress plugin directory and has a paid version to enhance features.

Let’s start with a step by step guide.

First login to your WordPress site then install and activate Auto Post Thumbnail plugin. Now go to Auto Featured Image» Generate Featured images option.

Set where you want to generate featured images automatically. Basically, it shows two options one is for post and another is page. So select one of them.

generate featured images

Here you will get other options to more customize your post’s featured image. The options are available only for its premium version. You can delete featured images at any time. 

Besides, you can add featured post images directly from Google image using the insert image option of this plugin. For using this feature, you need Google image API.

auto featured image general setting

You will get this feature under the General setting of the featured image plugin. But for this feature, you have to pay $55 for a lifetime.

For getting more benefits, there is an option to import bulk images to set as featured images on posts. Also, its image generation feature is really cool for advanced featured image design. 

With this feature, you can change featured image background color, image format(jpg and png), custom image size, etc. Additionally, you can add custom font and font sizes. Moreover, it supports adding appropriate image padding and align of featured images.

Image generation

Again this guide is only for busy bloggers and heavy publishers who have not enough time to design featured images separately. But it’s recommended to use a good-looking featured image for every post. 

You can use Canva to design excellent quality featured images for blog posts within a short time. 

Note: This guide is not for setting a default featured image for each blog post. If you want to add a default featured image for each post, you can use the default featured image plugin

If you don’t set featured images for each post manually, the plugin will add one default featured image automatically in every post.

If you have any questions, please comment below. I will try to answer in a short time and please don’t forget to share this guide with your friends and colleges using popular social media channels.

Previous

Thrive Themes Vs ClickFunnels: Which One Is Best?

Birchpress Scheduler Review: WordPress Appointment Booking Plugin

Next

Palash Talukdar is a digital marketer & the founder of WP Basic Pro. He has been building and managing WordPress websites for 5+ years. He loves to write about WordPress, SEO, marketing, productivity, and web performance.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.