Featured Image as Previous Next Post Navigation in WordPress

PHP, snippet, Wordpress, , Leave a comment

Just add this code to single.php, replace or comment the default function like the_post_navigation, get_previous_post, get_next_post, etc.

$prev_post = get_previous_post();
$prev_thumbnail = get_the_post_thumbnail( $prev_post->ID, 'large');

$next_post = get_next_post();
$next_thumbnail = get_the_post_thumbnail( $next_post->ID, 'large');

$args = array(
'prev_text'  => $prev_thumbnail,
'next_text'  => $next_thumbnail
);

the_post_navigation( $args );

Easy!