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 have a custom post type name->('portfolio'), with a taxonomy name ('portfolio_category'). what i want is to put next and previous link on its single page file which is single-portfolio.php. when i click either of the links it should redirect to the next or previous post in the same post type and in the same taxonomy term.

i used next_post_link() and previous_post_link() but it seems that it only works in single post but not in single custom post type..

please.. any idea guys.. any help will greatly appreciated..

share|improve this question
    
I can recommend the following plugin, next-previous-post-link-plus-for-wordpress I'm using it with 3.5.x without any problems. –  ialocin Jul 2 '13 at 13:53

2 Answers 2

This is what i use on my own site in my child themes functions file however you will need a theme which includes hooks or you will need to modify the code and use it in your single.php file.

    function wpsites_npp_navigation_links() {
    if( 'portfolio' == get_post_type() && is_singular('portfolio') ) {?>
    <?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 answer

try this is with thumbnail:

<?php $prevPost = get_previous_post(); if($prevPost) { ?>
    <li class="previous">
    <?php $prevthumbnail = get_the_post_thumbnail($prevPost->ID, array(80,80) ); ?>
        <?php previous_post_link('%link', $prevthumbnail . '<strong>Prev</strong> <span>%title</span>'); ?>
    </li>
<?php } $nextPost = get_next_post(); if($nextPost) { ?>
    <li class="next">
    <?php $nextthumbnail = get_the_post_thumbnail($nextPost->ID, array(80,80) ); ?>
        <?php next_post_link('%link', $nextthumbnail . '<strong>Next</strong> <span>%title</span>'); ?>
    </li>
<?php } ?>
share|improve this answer
    
Code-only answer is worst. Try to add some direction or description by editing it. :) –  Mayeenul Islam May 1 at 9:12

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.