3711 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 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?

3711 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 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..

94 posts Be different!
  • Has referred 500+ members
  • Has sold $1M+ on Envato Market and is now a Power Elite Author
  • Has collected 10+ items on Envato Market
  • Power Elite Author: Sold more than $1M on Envato Market
+4 more
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/

3711 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 more
KrownThemes says

Thanks for the link! :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by