• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • About
  • Projects

Self-Directed Reality

Actions are greater than Thoughts

  • Archive of My Thoughts
You are here: Home / Personal Development / Lessons Learned: Do Not Mess with the Functions.php file

Lessons Learned: Do Not Mess with the Functions.php file

February 21, 2017 by Paris Leave a Comment

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:

functions.php error from wpbeginner.com functions.php example
functions.php error from wpbeginner.com

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%.

    1. 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.
    1. 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.
    1. 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.
    1. 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.
  1. 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:

  1. Back up WordPress themes and plugins in files just in case of a raining day.
  2. Get a real backup plan establish for my ENTIRE site.
  3. 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. Β 

Follow @vincentcecelia on TwitterWork With Paris

Featured Image Credit: Photo by Markus Spiske on Unsplash

Filed Under: Personal Development Tagged With: How To, Lesson Learned

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

What’s on Your Mind?

Recent Posts

  • Inertia – The Loudness Found in the Unnatural Quiet of COVID October 18, 2021
  • Lesson Learned – Reflecting on February 2019 April 28, 2021
  • How 2020 became Year Zero January 11, 2021

Copyright © 2023 Β· Twenty Seven Pro on Genesis Framework Β· WordPress Β· Log in