Connecting all your posts together is not a bad way to make sure all of them are indexed in the search results.
Its also not a bad way to help increase a few extra page views as some of your readers will click your next & previous post links.
But lets face it, if you’ve setup and submitted a compliant XML sitemap you shouldn’t have anything to worry about it right?
In reality, there’s always something to worry about like:
- why aren’t all my url’s indexed!
- and why aren’t i getting more traffic!!
Lets take a look at the different ways you can add next and previous navigation links to different WordPress child and parent themes.
Adding Single Post Nav Links Using Code
To add post nav links to themes which don’t already include this function in the parent or child themes files, follow these steps.
You can simply add the template tags directly to your parent theme’s single.php file
Your single.php file is one of your templates used when displaying all single posts.
Add this code before the closing WordPress loop like i have done in this screenshot.
I have removed the text parameter in green so only the previous and next post titles will be displayed.
This code will display the post titles rather than the words previous and next post.
If you want to display the words, previous and next or custom text instead of your post titles, simply change the parameter in the code from yes to no. This will remove the post titles linked to your previous and next posts and only display the text in green which you can customize.
You could also use previous and next post with both post titles as well by changing the third parameter to yes as well as adding the previous and next text in the second parameter in green.
The navigation links will display on all single posts depending on where you paste the code in your single.php template file.
The most popular location is immediately after your post content so you would paste the code before your comments template like this:
Adding this code to your parent themes single.php template file is not exactly best practice because you’ll lose this function when you update the theme.
Better to hook it in using an after post content action hook (theme specific) and custom function.
Post Navigation Link Plugins
There’s many of these plugins in the WordPress plugins directory.
- WP Page Navi – Popular plugin for adding post and page navigation to WordPress.
Simply add this PHP code to your child themes functions file.
You have reached content available exclusively for members.