Add Custom Post Type Navigation Links in Genesis Themes
You can add post navigation links to custom post types in Genesis WordPress themes by using an existing function and just extending it. That function is genesis_prev_next_post_nav and is found in genesis/lib/structure/post.php
The function just refers to posts in the code but you can extend that by adding your own custom post types to an array which then add the navigation links to the posts that belong to the same custom post type.
So in your functions.php you can add a code snippet
Just add your own custom post type name, if you have just one custom post type that you want to have navigation links for, say only portfolio and not regular posts, you can just drop the array and add in…
The navigation links will appear in the footer of the post as we have added the function to be hooked into genesis_entry_footer
Navigation Previous/Next Text
By default the titles of the post are used as the linked text but you can change these – look at the code below and at the previous_post_link and next_post_link functions.
Hi Neil,
I have a CPT where I need the single post navigation to be in alphabetical order, not in post date order. Can you advise how to modify your code to achieve this?
Many thankls
Tim
Hi Neil,
Thanks you for these posts! I guess I need a different change. I like that next.prev links use the actual post titles as links. However I hate the little double karat arrows (» and «) (« » ) Is there a way to use the default Genesis action “genesis_prev_next_post_nav” but remove the stupid little arrows from the link text?
I did this but it does not change the text to “Previous Post” or “Next Post”. Instead it continues to show the post title. I copied the above code as-is into my functions.php file. What am I doing wrong?
Awesome just what I needed, thanks!
Thank you so much! This is exactly what I was looking for. It’s perfect.
Thanks so much! This is exactly what I was looking for.
One question though:
How do I display the words “Next” and “Previous” instead of the post link?
I’m guessing it has to do with replacing these functions at the end:
previous_post_link();
next_post_link();
Your help is greatly appreciated!
Hi, yes you can just change that part of the code to see the Gist link here –
https://gist.github.com/neilgee/0d8f266710c0daf7c28a