If you have a custom post type (for example – Portfolio), you might want to add Previous and Next buttons under each portfolio piece.
Here’s an example of that on this website: Single Porfolio piece. Notice at the bottom Previous and Next links go to other single pages of custom post type – Portfolio.
You need to add this code to your functions.php file (this example uses ‘portfolio’ custom post type, but you can change it to your custom post type):
Gist – Previous/Next Post Navigation in Genesis:
If you want to style your links, you can add this in your styles.css:
Gist – Style Previous/Next Post Navigation
Thank you for this! Exactly what I was looking for. I have one little problem: The next arrow actually goes to the previous page (and visa versa). I know nothing about PHP, is this an easy fix?
I updated the code to display actual post titles for Next/Previous links (just like on this website for Portfolio and Testimonials custom post types). Hope this fixes it.
Hi Irina, thank you for the article!
But I can’t seem to make it work.
I have a custom post type named cases, so I changed the code to “is_singular( ‘cases’ )”
but it didn’t work, is there something else I need to do?
Hi Victor,
It should work if you replace ‘portfolio’ with ‘cases’, if that’s your custom post type. Check to see if your singular_name is ‘cases’ or ‘case’ where you registered your custom post type. If it’s ‘case’, then make sure to put “is_singular(‘case’)”. It might also not work if there is a syntax error somewhere. If you’re using a text editor, like Sublime Text 3, it will show you any syntax errors.
Hope this helps
This. was. perfect. Thank you so much. I’ll get around to styling it, but for now, individual entries in my custom field type, with this snippet used via the code snippets plugin was a gloriously painless implementation.