php - Wrapping WordPress Latest Post Link
one text
Solution:
Use get_the_permalink
like so
/* If Featured Image Set */
if ( has_post_thumbnail($recent_post[0]['ID']) ){
$image = wp_get_attachment_image_src( get_post_thumbnail_id($recent_post[0]['ID']), 'full');
echo '<a href="' . get_the_permalink($recent_post[0]['ID']) . '">
<div class="featured-image-div" style="background-image:url('.$image[0].');"></div></a>
';
}
Function documentation: https://developer.wordpress.org/reference/functions/get_the_permalink/
Source