|

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! ?

Similar Posts

  • |

    Quick Tip: Add a Widget to WordPress

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!A couple of weeks ago I was working on a WordPress site and thought it might be nice to add a…

  • | |

    6 WordPress Plugins for Your Podcast Website

    WordPress is certainly the most popular CMS in the world, powering over 30% of the web. It also powers all sorts of websites, from blogs to giant e-commerce stores and everything in between. This includes podcast websites. However, recently I attended Podcast Movement, a fantastic podcasting conference, and discovered that many podcasters struggle with creating…

  • |

    Add Attachments to WordPress Search Results

    I feel like this has to have been done a lot, and there are great plugins out there for it, but if you’re just looking to add a quick function to your theme (or a really simple plugin) yourself, here’s how to modify WordPress’ search query to include attachments (like images). function attachment_search( $query ) {…

  • | |

    Testing Code Blocks with Ulysses

    Over on Twitter, Tom McFarlin asked me if Ulysses supports code syntax when pushing to WordPress: https://twitter.com/tommcfarlin/status/1526909277352480769 So I decided to give it a test: Looks good! And here’s what it looks like in Ulysses:

  • Speaking: NEPABlogCon and Beyond!

    Though I haven’t officially announced it yet, I have been talking for a while about a new book I’m working on called Responsive Design with WordPress. We are a couple of months out from release but things are going well! In the time running up to the release I’ll be out there speaking quite a bit to…