1

I'd like to add next and previous post links on single posts which use a custom post type. Prefer links only work for the posts assigned to the custom post type.

How would i add it to this:

function wpsites_npp_navigation_links() {
if( 'portfolio_post_type' == get_post_type() ) {?>
<?php previous_post('&laquo; &laquo; %', 'Previous', 'no'); ?>
 | <?php next_post('% &raquo; &raquo; ', 'Next', 'no'); ?>
<?php
} }

add_action('genesis_after_post_content', 'wpsites_npp_navigation_links', 5 );

Worked this out myself. Here's the solution for HTML 5 enabled Genesis child themes. Change to the old hook if you haven't added child theme support for HTML 5.

Example: From genesis_entry_footer to genesis_after_post

function wpsites_npp_navigation_links() {
if( 'portfolio' == get_post_type() ) {?>
<?php previous_post('&laquo; &laquo; %', 'Previous', 'no'); ?>
 | <?php next_post('% &raquo; &raquo; ', 'Next', 'no'); ?>
<?php
} }

add_action('genesis_entry_footer', 'wpsites_npp_navigation_links', 5 );

2 Answers 2

1

A simple solution is to edit your single.php template file and wrap the calls to previous and next post link with a check of the post type:

if( 'your_post_type' == get_post_type() ) {
    previous_post_link();
    next_post_link();
}
0

There's also a great plugin which does this automatically: http://wordpress.org/plugins/genesis-single-post-navigation/.

1
  • This plugin has been "closed" and is no longer available. Nov 25, 2019 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.