Featured Image as Previous Next Post Navigation in WordPress

Last Updated: June 27, 2020 | Reading Time: < 1 minute

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!

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

    Any idea? Fill the comment below

    This site uses Akismet to reduce spam. Learn how your comment data is processed.