If you’ve ever been faced with 404’s and broken links after a site migration or web address change – then this post is for you! You can prevent this from ever happening again with future-proofed links. Future-proofed links are links that are written with the future in mind. So in our case, the future might be that the site moves from it’s current place and/or the web address changes. And in the event that either one of those situations happen, these future-proofed links will automatically update and prevent broken links. No more 404’s – hurray! Great, so how do we create these future-proofed links? Easy peasy. ( I never say easy peasy in real life, writing does that to you… ) Here are a few code snippets to help you out. Before we get started, this quick post assumes that you have a permalink setup that is anything, but the default – “pretty permalinks” as some call it. Future-proofing in the Theme * When building or editing an existing WordPress theme, the first practice you’ll want to stop doing is hardcoding urls. What I mean by this is writing out the urls manually. Here’s an example of what you don’t want to do anymore: The problem with the above is if you decide somewhere down
Share This