3507 posts Ruben Bristian
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly helped protect Envato Market against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
  • Referred between 500 and 999 users
+5 more
KrownThemes says

I can’t seem to find anything on this subject on the internet. The basic function works perfectly fine. The issue starts when i try to filter things in the same category or exclude categories:

get_next_post(); // returns a perfectly normal object which contains the data of the next post
get_next_post(true); // returns an empty object, even if there are a lot more posts in the same category
get_next_post(false, '34'); // returns an empty object, even if there are more posts in other categories except 34

Has anyone encountered this error?

3507 posts Ruben Bristian
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly helped protect Envato Market against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
  • Referred between 500 and 999 users
+5 more
KrownThemes says

I think i’ve answered my own question here… get_adjacent_post() (from wp-includes/link-template.php) use the “category” to search in the WP database. This is obviously limited, because any CPT categories are “cpt_category”, so the query is wrong from the start. I guess the only solution would be to fork the function inside the theme..

92 posts Be different!
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Referred between 500 and 999 users
  • Exclusive Author
  • Has been a member for 3-4 years
  • Bought between 10 and 49 items
UnitedThemes says

Hi Ruben,

yes you are right, we ran into this issue too. Maybe this article here helps you: http://www.billerickson.net/previous-and-next-post-in-same-taxonomy/

3507 posts Ruben Bristian
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly helped protect Envato Market against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
  • Referred between 500 and 999 users
+5 more
KrownThemes says

Thanks for the link! :)

by
by
by
by
by
by