Multiple Featured Images | WordPress.org

Hi Elaine,

Yes this is possible, with a bit of custom code.
In your wp-content/plugins/ folder create a file named: dfi-random.php
With the following code:

<?php
/**
 * Plugin Name: Default Featured Image - Random post image
 * Plugin URI:  https://projectdmc.org/support/topic/multiple-featured-images-6/
 * Version:     1.0
 */

add_filter( 'dfi_thumbnail_id', 'dfi_random_image', 10, 2 );
function dfi_random_image( $dfi_id, $post_id ) {
	if ( get_post_type( $post_id ) !== 'post' ) {
		return $dfi_id; // This is not a post, we only check posts.
	}
	$random_image_ids = array(
		123, # Add your image id's in this array.
		456,
	);

	return $random_image_ids[ array_rand( $random_image_ids ) ];
}

Replace the example image ids (123, 456,) with your own image ids.
You can find the image ids in the media library when you open an image and check the url.

After you change the id’s don’t forget to activate the plugin.

If you need any help let me know.
Jan-Willem

Thankyou. Much appreciated.

 

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