Most of this code is unnecessary. Remove everything inside the foreach
from your question and just use:
foreach ( $recent_posts as $recent_post ) {
$image = get_the_post_thumbnail( $recent_post, 'medium' );
// etc.
}
Most of this code is unnecessary. Remove everything inside the foreach
from your question and just use:
foreach ( $recent_posts as $recent_post ) {
$image = get_the_post_thumbnail( $recent_post, 'medium' );
// etc.
}