I’m trying to create links to the next and previous posts within a specific tag (on the post page itself), but I can’t seem to find a plugin or source that does this.

I want to be able to something like this, appearing below the post.

get_previous_link("tagname");
get_next_link("tagname");

Anybody know of a way to accomplish this? Otherwise I’ll have to write something myself, which is fine, but I figured I wouldn’t reinvent the wheel unless I have to.

3 s
3

get_adjacent_post(), which is used by all functions that return a (link to) the next or previous post, only has a $in_same_cat argument, which looks at the categories the post is in, not the tags.

You could hook into the get_[next|previous]_post_join to modify the join query for your call, but then it’s probably easier to copy the function, remove the category-specific code and replace it with tag-specific code. Or make it even more generic and submit it as a patch to WordPress 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *