-1

I need help with displaying the featured image of the previous/next post.

I'm not a coder and have been trying to search for solutions in this forum & online.

Here are my codes (single.php):

<?php $prevPost = get_adjacent_post( false, '', true );
    if($prevPost):
?>

<a class="previous" href="<?= get_permalink($prevPost->ID); ?>">
    <p><?= $prevPost->post_title; ?></p>
</a>

<?php endif; ?>

How do I output the featured image of the Previous Post?

Thanks for your help in advance!

Alvin

0

featured image url function passed post id and image size

<?php $featured_img_url = get_the_post_thumbnail_url($prevPost->ID,'full'); ?>

<img src="<?php echo $featured_img_url; ?>" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.