|

New Plug-in: Latest Post Redirect

One thing I often forget to do is update social links when I’m promoting a new blog post or podcast episode. Especially on Instagram, I’ll say something like, “link in the profile,”1 only to forget to add the link to the profile! Services like Linktree help a little, but you still need to update. Well over a couple of days, I built a plugin to help me (and hopefully you) with this little problem.

I Miss Coding

First, let me just tell you how much I miss coding on a regular basis. It’s so much fun to scratch an itch and solve a problem. And your code projects don’t need to be these huge feature-rich monoliths. One-off, super focused apps or plugins are all the rage these days! And that’s what I decided to do.

Introducing Latest Post Redirect

I created a simple plugin that accomplishes a single task:

Create a redirect called [YOUR-DOMAIN]/latest that redirects to the most recently published post.

That’s it. It’s 43 lines with comments and does 2 things:

  1. Checks the current URL to see if /latest or /latest/ is at the end of the URL
  2. If it is, get the permalink of the most recently published post and redirect the user to that link.

You can download the zip from Github

Live Streaming the Process

Over the last two weeks, I used my Live Stream to code it. The project took a little less than two hours for me to:

  1. Understand how redirects work in WordPress across different server types.
  2. Work out how to do a redirect the right way with WordPress
  3. Grab the latest post (the easiest part for me)
  4. Write a regular expression to check the link for exactly two cases: /latest or /latest/

If you’d like to see me built it out (and a glimpse into my brain when I code), you can watch both parts here:

Be sure to subscribe to my YouTube channel to catch the next live stream!

  1. When will Instagram finally let us add links to descriptions. Doesn’t even need to be comments. Just descriptions! ?

Leave a Reply

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