|

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

  • I’m Speaking at WordCamp Baltimore!

    The last WordCamp I went to was WordCamp Chicago in June, with it rounding out a big tour that started in January to promote my book, Responsive Design with WordPress. While I took a much needed break (and started a new job thanks in part to that trip), I’m really excited to announce that I’ll…

  • |

    Why the WordPress.com / Spotify Deal is Bad for Podcasting

    Imagine telling Gordon Ramsay that he cooked dinner last night…why not just serve the leftovers to his customers today? While I’m no Michelin chef, I do create a lot of content. And you can’t just throw the left overs out there and expect the same quality content. So why are WordPress.com and Spotify telling us to do that?

  • |

    Do we REALLY Need to Own Our Platform?

    Last week’s Facebook outage brought an onslaught of platitudes from people talking about how terrible Facebook is, and how you should own your own platform. But even as a developer myself, my thoughts are a little different.

  • |

    Upcoming News & Events

    Whoa. Almost a month has gone by and I haven’t written a thing on this blog; sorry about that! Since officially announcing my new book, Responsive Design with WordPress, I’ve been working diligently to finish up all of the writing, reviews, edits, and design approvals. I’m happy to say that Monday I will be done…

  • |

    Join Me for CigarCamp at WordCamp US!

    With WordCamp US quickly approaching, I thought it would be fun to have an informal CigarCamp US while everyone is in town. Here are the details: Location: Ashton Cigar Bar (map) Date: Friday, December 4th Time: 9:00pm – 11:00pm EST Head on over to the site and sign up! There will be cigars, scotch, and WordPress talk. And…