Any tricks to bulk replacing multiple post featured images with a single image?

[ad_1]

I have more than 100 posts that have the same featured image, and I'd rather replace them all with a single image and then delete the old images.

Goals

  • Replace the old image with optimized image on all the posts that have the repeated image.
  • Only have to update the alt and description in one place
  • Free up storage space

Any tricks or plugins to do that?

[ad_2]
3 Comments
  1. There should be a filter for the featured image.

    In fact seems to be this:

    function use_specific_post_featured_image($html, $post_id, $post_image_id) {
    // ID of the post whose featured image you want to use
    $specific_post_id = 123;

    // Get the featured image ID of the specific post
    $specific_post_image_id = get_post_thumbnail_id($specific_post_id);

    // If the specific post has a featured image, use it
    if ($specific_post_image_id) {
    // Get the HTML for the specific post’s featured image
    $html = wp_get_attachment_image($specific_post_image_id, ‘full’);
    }

    return $html;
    }
    add_filter(‘post_thumbnail_html’, ‘use_specific_post_featured_image’, 10, 3);

    Add it to functions.php

  2. Without going the technical route, you can replace the old photo with the new one via FTP and use Thumbnail regenerate plugin to recreate the sizes.

    Of course, this assumes the same image used is the same attachment ID each time.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer