The latest release of the WordPress plugin Redirect URL to Post comes with another useful enhancement: Using redirect_to=prev and redirect_to=next you can send your website visitors to the previous or next post.
The post order is determined by publishing dates. Unlike when using hard-coded links to previous and next posts, we identify the target post only at the time when a visitor enters the link. We also match the post type of the current post. Yes, it even works with pages, although there might not be many cases where pages have a chronological order.
These new parameters have not been tested in combination with others, except “offset”, which lets you go to the 1st, 2nd, … after the next or previous post. You definitely cannot use with them “post_type”, “before” and “after”.
No Jumping the Queue
Since we need to know the ID of the current post in order to find out where to go, the plugin has to wait a bit longer than usual until it can spring into action. I haven’t seen it during testing, but theoretically it might happen that another plugin has already sent some output to the browser and you will see an error message: “Headers already sent”.
Unfortunately, there is not much we can do about those hasty plugins. We particularly cannot jump the queue and run earlier, since we don’t know where we’re heading before we know the post ID.
For all other redirect_to options we still hook earlier into the WordPress workflow. No change here.
Available Now
The new version is available on your admin backend. Or go to the WordPress plugin repository where you will find it waiting just for you.
Photo by Christoph Amthor