A URL to the Latest Post

Redirect URL to Post banner

After three years I have published now another WordPress plugin: Redirect URL to Post. As before, the reason was that I couldn’t find any other plugin providing what I needed.

What I needed was a link that I could use on other sites and that would redirect to the latest post in a particular category. To be more concrete, I pulled the latest post of a blog to a weekly Mailchimp newsletter. Naturally readers of the newsletter should be taken to the full post by clicking on the title or “read more” link. But even after hours of trying, I did not manage to retrieve the post’s permalink with Mailchimp’s shortcodes.((possibly due to a bug in their system, or a malformed RSS feed)) So instead I used the link to the entire list of posts of that category – better all than nothing – and readers would from there have to click on to the latest post. Then, however, I realized that it would be very handy to have a special URL that would automatically redirect to the latest post so that I wouldn’t have to worry about updating that link.

This idea resulted in the appended parameter “redirect_to” and the required category ID:

www.ecoburma.com/?redirect_to=latest&cat=151

… which can be translated to:

Redirect to the currently latest post on www.ecoburma.com in the category with the ID 159 (i.e. “blog”).

Additionally to “latest” (or “last”), I implemented also “oldest” (or “first”), “random” and “custom”. “Custom” means that the order is not determined by the date of publishing or a (pseudo) random order but by what you specify with an additional “orderby” parameter. So now you can automatically link to the post with, say, the highest number of comments.

There are numerous other plugins that show a list of latest posts, using shortcodes, or that display them in a widget. What I needed, however, was to make them directly accessible through an URL, and to display the single post rather than a list.

Naturally, this plugin doesn’t need any persistent settings and therefore there is no settings page in the admin back end. It is actually quite simple and doesn’t even change anything in the database.

The plugin already has its own page where I will update all related information.

Now I am curious if it might be useful for anyone else too.