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?

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

2 Answers 2

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.

1
  • Hi בניית אתרים, thanks for your answer, worked perfect.
    – Thomas
    Commented Jan 30, 2011 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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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