1

I want to use next_post_link and prev_post_link to return only the next post in my custom taxonomy of a custom post type. I have a custom post type called "work_posts" which has the taxonomy "work_categories" assigned. The category I want to show is called 'all'. I looked up get_adjacent_post in the "link-template.php" which has a few filters which should make it possible to make such a query but my SQL is not good enough to make the right query. The hooks are:

  • get_{$adjacent}_post_join
  • get_{$adjacent}_post_where
  • get_{$adjacent}_post_sort

if I log a query in the join hook I get:

INNER JOIN wp_term_relationships AS tr 
ON p.ID = tr.object_id 
INNER JOIN wp_term_taxonomy tt 
ON tr.term_taxonomy_id = tt.term_taxonomy_id 
AND tt.taxonomy = 'category' 
AND tt.term_id IN (3)

how do I modify this to only show posts from my custom taxonomy?

  • Why not use query_posts or wp_query ? What's the need for sql here – Bainternet Jan 29 '11 at 16:23
2

Take a look at http://wordpress.org/extend/plugins/ambrosite-nextprevious-post-link-plus/ Its a plugin that adds extra missing functionality to next_post_link and prev_post_link functions.

| improve this answer | |
  • Hi בניית אתרים, thanks for your answer, worked perfect. – Thomas Jan 30 '11 at 23:06
2

I was with the same problem.

The correct plugin to be used to fix the problem is this.

And it seems that a bug is already reported here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.