Toolset Types
[resolved] Previous | Next links for custom post types (13 posts)

  1. Nathan Gross
    Posted 2 years ago #

    I'm trying to create some navigation to move between custom post (types).

    I have a custom post called portfolio-projects. I'd like to be able to go to the previous and next posts in that custom type.

    It seems the standard wp codex is not working <?php posts_nav_link(); ?>


  2. Srdjan
    Posted 2 years ago #

    Hi Nathan,
    can you describe little more how are you using posts_nav_link()?
    = Which theme you're using?
    = Which template is calling navigation?
    = Are there enough posts created to get navigation?

    Default WP themes work fine with custom post navigation.


  3. Nathan Gross
    Posted 2 years ago #

    Hi Srdjan,

    Thanks for the response.

    Which theme you're using?

    The theme is one we are custom building

    Which template is calling navigation?

    It's a custom single post page (single-portfolio-projects.php)

    Are there enough posts created to get navigation?

    Yes, there are many posts.

  4. Nathan Gross
    Posted 2 years ago #

  5. Michael
    Forum Moderator
    Posted 2 years ago #

    posts_nav_link() will only work in index or archive pages;


    see also the remarks regarding single posts near the start of that Codex doc.

  6. Srdjan
    Posted 2 years ago #

    right, you can use:
    previous_post_link() and next_post_link()
    in single post template.

  7. Nathan Gross
    Posted 2 years ago #

    One thing I failed to mention was that we only want the next/previous post in the current category.

    We have a custom post type of 'Portfolio' with three categories/taxonomies: Hotrod, Custom, and Misc.

    Our single post page is and should only show one category of posts at a time. The prev/next should navigate between this category only - not the other categories.

    Currently we are using:

    echo previous_post_link('%link', 'Previous', $in_same_cat = true);
    echo next_post_link('%link', 'Next', $in_same_cat = true);
  8. Srdjan
    Posted 2 years ago #

    Note that $in_same_cat works fine with Categories but not with other custom taxonomies.

    So this should work fine if you expect link to post in same Category:
    previous_post_link( '%link', 'Previous', true );

  9. Nathan Gross
    Posted 2 years ago #

    Thanks for all the help. We have it working as intended now.

    The previous_post_link and next_post_link works as intended. We had a plugin that was conflicting with the order and we therefore thought the prev/next was not working correctly.

  10. jaroljmek
    Posted 2 years ago #

    Hi there

    My theme author - Webtreats/Mysitemyway - put me onto this thread. I'm also trying to add a previous/next to individual Portfolio pages. It is a site with 50 auction lots so putting manual links from each page to the next is a last resort!

    http://www.circleartagency.com/auction - the individual auction lots link from this page.

    I found a simple plugin that works with standard pages (called Next Page) but it doesn't work with Portfolio pages.

    I don't have the coding skills to customise but I can make changes to theme files if given reasonably simple instructions. I'm sure it's a fairly easy customisation as I can see above. I just don't know where to make the amendments that Nathan Gross has successfully made above.

    I'd be massively grateful for any assistance with my learning curve. (It's a Kenyan client - they don't have money to employ developers).

    Many thx
    Christian Jaroljmek

  11. esmi
    Forum Moderator
    Posted 2 years ago #

    I'm sorry but as you are using a commercial theme, you need to seek support from the theme's developer/vendor. We do not support commercial products here.

  12. ws
    Posted 2 years ago #

    I am having a somewhat similar issue. I can set the $in_same_cat to TRUE and the links completely disappear. Setting them to FALSE, they work properly but I am looking to only have prev/next go within the current category.

    I am using a custom post type called "Portfolio" with a lot of categories. This is my current code for single_portfolio.php:

    <?php if(get_the_term_list($post->ID, 'portfolio_category', '', '<br />', '')): ?>
    <div class="project-info-box">
    <div id="single-nav-left"> <?php previous_post_link('%link', '&laquo; Previous', FALSE); ?>&nbsp;&nbsp;  |  </div>
    <div id="single-nav-right"><?php next_post_link('%link', 'Next &raquo;', FALSE); ?></div>
  13. WPyogi
    Forum Moderator
    Posted 2 years ago #

    @WS-Craig - this thread is resolved. Please start your own thread per


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Toolset Types
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic