[ad_1]
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:
* 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.
