[Resolved] Previous | Next links for custom post types
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(); ?>
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.
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.
You can see the site here:
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.
right, you can use:
previous_post_link() and next_post_link()
in single post template.
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);
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 );
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.
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).
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.
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', '« Previous', FALSE); ?> | </div> <div id="single-nav-right"><?php next_post_link('%link', 'Next »', FALSE); ?></div>
@ws-craig – this thread is resolved. Please start your own thread per
- The topic ‘[Resolved] Previous | Next links for custom post types’ is closed to new replies.