Move Pagination Directly Under Post in WordPress

Move-Pagination-Directly-Under-Post-in-WordPress
0
()

When using the WordPress pagination feature, with some themes it can end up being out of the way and your visitors might not see it. This can cause issues where you visitor will get frustrated and leave your website. This also then starts to push up your bounce rate.

I had this problem so I wanted my pagination buttons to be directly underneath my post, so that it was clear to my visitors how to get to the next page.

Plugin v Code

There are a number of plugins you can use to do this but I already use far too many plugins as it is, so I wanted to code it into my theme.

I started Googling how to do this and I came across a post on Stack Exchange which offered a solution. I tested it out and it worked a treat.

Below is the code that allows you to have your pagination buttons just below your post. This should be copy and pasted into your functions.php file – I suggest adding this to your child theme so that it does not disappear on the next theme update.

Pagination Buttons Code

<?php // move pagination links above other end-of-post content additions, like related posts etc.
function move_pagination( $content ) {
if ( is_single() ) {
$pagination = wp_link_pages( array(
'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'firmness' ) . '</span>',
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
'echo' => 0,
) );
$content .= $pagination;
return $content;
}
return $content;
}

add_filter( 'the_content', 'move_pagination', 1 );

Bad Syntax

Please be very aware – if you do copy and paste this code above, check the syntax as the formatting can get a little messed up, always check speech marks as this is normally what get screwed up on copy and pasting from the internet.

Feedback

If you have any questions or comments on this post, please feel free to either leave a comment below or use one of our many social media platforms.

Credithttps://wordpress.stackexchange.com/questions/168498/how-to-add-pagination-in-between-post-and-comments?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

Related...  Google Chrome MSI Installer Version 80.0.3987.87

Newsletter

If you want to be notified when we post more quality guides like this one, sign up to our newsletter and you will receive an email when a new post is live.

Join 450 other subscribers.

Don’t worry, we won’t be filling your inbox with spam and you can unsubscribe anytime you like.

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

About A.J. Armstrong

Founder of TechyGeeksHome and Head Editor for over eight years! IT expert in multiple areas for over 21 years. Sharing experience and knowledge whenever possible! Making IT Happen.

View all posts by A.J. Armstrong

Leave us a message...

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