Skip Navigation

[Resolved] cannot get next previous navigation links to show on custom post types

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Tagged: 

This topic contains 3 replies, has 3 voices.

Last updated by Tiago Valente 6 years, 2 months ago.

Assigned support staff: Shane.

Author
Posts
#314573
nonavlinks.PNG

I am trying to:
display next and prevoius nav links on single posts of custom post types, for example, team-member

I visited this URL:
hidden link

I expected to see:
the nav links, after adding the function to my functions file as described in topic below

 
/*genesis next previous */

add_filter( 'genesis_prev_link_text', 'gt_review_prev_link_text' );
function gt_review_prev_link_text() {
        $prevlink = 'Previous';
        return $prevlink;
}
add_filter( 'genesis_next_link_text', 'gt_review_next_link_text' );
function gt_review_next_link_text() {
        $nextlink = 'Next';
        return $nextlink;
}

function prefix_navigation_links() {
    if ( is_singular('team-member') ) {
    ?>
        <span class="nav-previous alignleft"><?php previous_post_link('%link', 'Previous Post', TRUE) ?></span>
        <span class="nav-next alignright"><?php next_post_link('%link', 'Next Post', TRUE) ?></span>
       <?php
    }
}
add_action('genesis_after_entry', 'prefix_navigation_links' );

Instead, I got:
no nav links

https://toolset.com/forums/topic/nextprevious-page-pagination-on-content-template-for-cpt/

#314612

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Marisa,

Thanks for contacting our support forum.

In order for you to add the navigation buttons to your post pages you need to modify the theme's template file itself.

The template file for a post is normally a single.php file.

You need to modify that file by adding this to it.

<?php prefix_navigation_links(); ?>

Before you add that to the template file you must first add this to your theme's functions.php file.

 
function prefix_navigation_links() {
    if ( is_singular('team-member') ) {
    ?>
        <span class="nav-previous alignleft"><?php previous_post_link('%link', 'Previous Post', TRUE) ?></span>
        <span class="nav-next alignright"><?php next_post_link('%link', 'Next Post', TRUE) ?></span>
       <?php
    }
}
add_action('genesis_after_entry', 'prefix_navigation_links' );

Please let me know if you are experiencing any issues with this.

Thanks

#314794

Hi, I just wanted to let you know that I couldn't use the above method because you shouldn't/can't modify Genesis templates, but rather hook in with a function in the functions file. So I had to keep searching for the answer (seeing that your topic pointed me in the right direction of modifying Genesis, not of using a Views shortcode in the content template).

I thought I had to do this using a Views shortcode. After hours of searching before and after I opened this ticket, I found this article, which shows exactly how to do this:
hidden link.

Navs are shown here - I'll be styling them of course.

hidden link

Thanks for helping me in the right direction. I just wanted anyone who finds this post to find the smoothest solution.

Marisa

#1096293

Hi Marisa,

Could you please provide the link from where you solved this issue? I'm trying to replicate.

thanks