Question

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

Was it helpful?

Solution

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 );
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top