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('« « %', 'Previous', 'no'); ?>
| <?php next_post('% » » ', '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('« « %', 'Previous', 'no'); ?>
| <?php next_post('% » » ', 'Next', 'no'); ?>
<?php
} }
add_action('genesis_entry_footer', 'wpsites_npp_navigation_links', 5 );
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:There’s also a great plugin which does this automatically: http://wordpress.org/plugins/genesis-single-post-navigation/.