next_post_link() not working for single custom post type post

Ok, I found the solution in terms of getting the links to appear, however, I needed to remove the ‘true’ argument for only moving between posts in the same category/taxonomy.

Is that right that you can’t restrict the posts linked to so that they’re only the ones within the same taxonomy? Here’s the correct code and as vancoder says, it needs to appear within the loop (I placed this just before endwhile;):

<div class="next-posts"><?php next_post_link('%link', 'Newer entry &gt;') ?></div>
<div class="prev-posts"><?php previous_post_link('%link', '&lt; Older entry') ?></div>

As this is a custom post type with a custom taxonomy, I assume the pagination is breaking because WordPress is looking for a ‘category’ as if these were normal posts? Is there any way to make this work so that only Work posts within my custom taxonomy are returned?

Leave a Comment