So, does this go in the wp-contents/plugins/
folder or in the wp-contents/plugins/default-featured-image/
folder?
And in my case, please tell me if I have done it correctly:
<?php
/**
* Plugin Name: Default Featured Image - Random post image
* Plugin URI: https://www.ads-software.com/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(
206952, # Add your image id's in this array.
206951,
206950,
206949,
206948,
206947,
206946,
206945,
206942,
206941,
);
return $random_image_ids[ array_rand( $random_image_ids ) ];
}