Display Previous Next Post link at Bottom of Post in WordPress

Displaying previous and next post link at the bottom of the post will make the user to click on that link and check other posts. It also increases the traffic rate. Here is the tutorial for how to display previous next post link at Bottom of Post in wordpress.
This is done by simple coding to be placed in functions.php and style.css and not by installing plugins
WordPress Admin Panel -> Appearance -> Editor -> functions.php
Place the following code inside functions.php file

functions.php

function next_prev_link($link) {
if(is_single())
{
$prev_post = get_previous_post();
if (!empty( $prev_post ))
{
$link .= '<a href="'.get_permalink($prev_post->ID).'" class="prev"><< '.$prev_post->post_title.'</a>';
}

$next_post = get_next_post();
if (!empty( $next_post ))
{
$link .= '<a href="'.get_permalink( $next_post->ID ).'" class="next">'.$next_post->post_title.' >></a>';
}
}
return $link;
}
add_filter('the_content', 'next_prev_link');

WordPress Admin Panel -> Appearance -> Editor -> style.css
Place the following code inside style.css file
style.css

.prev, .next
{
display: block;
}
.prev
{
float: left;
}
.next
{
float: right;
}
(Visited 49 times, 1 visits today)

Leave a Comment.