Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 );
share|improve this question
add comment

2 Answers

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();
}
share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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