Lessons Learned – Experiences distilled from a project that should be actively taken into account in future projects. Lessons Learned is where I document my fuckups lessons from my day-to-day life experiences.
This warning is plastered over everything as I search around the web trying to learn how to edit my theme on my site. Of course, I only believe in learning by doing.
And I don’t believe it is called “learning” if you are doing something right. So here I was a few nights ago trying to figure out why iframes do not display correctly in the newest version of WordPress.
I am not going to get too technical, just know that iframes are kinda important for embedding things on your site that are hosted elsewhere (like for example, a YouTube video or a JavaScript game). Trust me, when you write a blog and see something interesting, you will want to link it in your blog. So anyways, I find some code online (*I know* π that I can place at the bottom of the functions.php file in my WordPress theme. This code would allow my site to use iframes going forward without an issue in my blog posts.
Well if it would have worked…
It didn’t work. Not only did it not work, it actually brought down my site. I was unable to view the site OR even log in from the back-end. I got an error similar to the one below when I tried to access my site through any means:
What this meant was that I was unable to log back into my site to FIX the error I created. So the only solution I had was to go to my hosting site and get my FTP (File Transfer Protocol) credentials to remote into back-end of my hosting server. So I won’t bore you with details but I tried 5 different methods to fix this issue of which only one worked 100%.
-
- Solution 1 – Restore a previous backup of my site using Updraft, the free plugin.
Outcome – FAILED. Updraft Free only backs up media on my site it seems and not the WordPress files and themes. This actually spurred me into looking for a REAL backup solution because I realized the shortcomings of it when I actually needed it.
- Solution 1 – Restore a previous backup of my site using Updraft, the free plugin.
-
- Solution 2 – FTP into the back-end, download the functions.php file and edit out the change I made.
Outcome – FAILED. Apparently after I copied the file, made changes and deleted the original, WordPress decided it didn’t want to play ball with my corrected functions file.
- Solution 2 – FTP into the back-end, download the functions.php file and edit out the change I made.
-
- Solution 3 – Delete the corrupted functions.php file from the server and let WordPress create a new one!
Outcome: – FAILED. After some testing, I was able to get back into my site and see it but my theme was all bananas. Turns out that WordPress themes DO NOT recreate corrupted missing files.
- Solution 3 – Delete the corrupted functions.php file from the server and let WordPress create a new one!
-
- Solution 4 – Change the theme from my currently selected one and get a new one and then switch back to my original.
Outcome – FAILED. Along the lines of the thought process above, switching themes doesn’t mean WordPress would regenerate missing/corrupted files either. Makes sense once you think about it but I figure I would give it a shot.
- Solution 4 – Change the theme from my currently selected one and get a new one and then switch back to my original.
- Solution 5 – Find the original functions.php for the theme and upload it to my site through FTP.
Outcome – SUCCESS. It works perfectly without an issues.
This is why you should have your original theme files backed up somewhere else just in case of situations like this. I didn’t actual have the files on my machine and the site where I got my theme actually went down (so I couldn’t re-download the clean files). Fortunately I had the files on another machine I rarely use and I was able to copy over the functions.php to my WordPress site. I learned a few things from this incident:
- Back up WordPress themes and plugins in files just in case of a raining day.
- Get a real backup plan establish for my ENTIRE site.
- Dont mess with functions.php in WordPress. Set up a clone website for testing.
βββββββββββββββββββββββ
If this content resonated with you, let me know on Twitter. I am always eager to talk to like-minded people. And if you need help with your own projects, allow me to bring your Visions into Reality byΒ clicking the Designed by Paris below. Β
Featured Image Credit: Photo by Markus Spiske on Unsplash
Leave a Reply