Display Previous Next Post link at Bottom of Post in WordPress

By | January 3, 2014

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
.prev, .next
{
display: block;
}
.prev
{
float: left;
}
.next
{
float: right;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

intermittently-areosystyle