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.

 

Ref

7 Comments

  1. Tim on May 22, 2022 at 9:37 am

    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

  2. Rob R on January 9, 2018 at 2:07 am

    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?

  3. Chris on December 16, 2017 at 3:50 pm

    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?

  4. Noah on September 26, 2016 at 8:46 am

    Awesome just what I needed, thanks!

  5. Marj Esch on July 22, 2016 at 12:40 pm

    Thank you so much! This is exactly what I was looking for. It’s perfect.

  6. Shon on March 19, 2016 at 8:20 am

    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!

Leave all Comment