Images of the latest posts in wp are not displayed. What is the problem?

<div class="new-posts"> <?php $recent_posts = wp_get_recent_posts(3); foreach($recent_posts as $post){ echo '<div class="new-post"><a href="' . get_permalink($post["ID"]) . '" title="'.$post["post_title"].'" >'; ?> <img src="<?php wp_get_recent_posts($post["ID"]); ?>" alt=""> <?php echo '</a><a class="link" href="' . get_permalink($post["ID"]) . '" title="'.$post["post_title"].'" >' . $post["post_title"].'</a></div>';}?> </div> 

    1 answer 1

    The problem is that you are trying to get a link to an image with the wp_get_recent_posts() function. Use, for example, the function get_the_post_thumbnail_url()

     <img src="<?php echo get_the_post_thumbnail_url($post["ID"]); ?>" alt="">