Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Kevin Murphy
Kevin Murphy
24,380 Points

functions.php -- Editing within theme caused parsing error, could not undo

Wanted to share an experience I had when attempting to modify my site's functions.php file. This was my first attempt modifying this file, figuring I could just delete the added code if things went awry.

I added code straight from codex but I must have placed it incorrectly as I received a parsing error. This error remained after I deleted the added code. I also could not access any of the WP admin menu options.

After some (frantic) digging I learned from a prior Wordpress support forum post that modifying the functions.php file is "non-reverseable". Even when you delete the offending code, the issue will remain.

Ultimately all turned out ok, but I had to go into cPanel and replace my functions.php file and reinstall my theme to restore back to normal.

Apparently it is common practice to make a copy of functions.php before making any changes to this template. I had no awareness of this and wanted to pass along. If you experienced anything similar, and/or have tips to share, please let me know.

3 Answers

Sean T. Unwin
Sean T. Unwin
28,690 Points

A good lesson learned the hard way. Heheh.

It's advisable to not edit files from within the admin dashboard. As you mentioned:

  • backup your theme
  • copy/download the file you want to edit
  • make your edits
  • test locally
  • then upload the 'new' file which will overwrite the old one on the server.

Hi Sean !

Kevin Murphy
Kevin Murphy
24,380 Points

Ahh local testing - so much to remember, I didn't even consider that. That is excellent advice. Will definitely be part of my new process. Thanks!

Are you talking about the functions.php in wp-includes folder?

Kevin Murphy
Kevin Murphy
24,380 Points

Leonardo - the functions.php file inside the theme that makes up the core set of theme templates.