2

Is there a simple way to use the post thumbnail when calling previous_post_link() and next_post_link()?

1 Answer 1

10

This could be acheived by using the get_previous_post() and get_the_post_thumbnail() functions. Then just pass the thumbnail value into the second parameter of previous_post_link().

$prevPost = get_previous_post();
$prevThumbnail = get_the_post_thumbnail( $prevPost->ID );
previous_post_link( '%link', $prevThumbnail );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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