I received a WordPress emergency email from a friend/client last night and I wanted to share both the problem, and the solution, with you. Now, I am far from a WordPress expert, but having faced some issues myself, her problem was one that I could solve.
My friend was trying to modify an existing theme on her WordPress blog and one thing she really wanted was to expand the theme to include 3 column, instead of just 2. I have often had the same desire for more sidebar space, so I could understand why she wanted to do this.
Using the WordPress Admin interface she had entered into the Appearance area and clicked Editor to access the php and HTML code that underlies all WordPress themes. In editing one of these files though, she made a coding mistake, or a typo, and suddenly she could no longer access the Admin pages for her WordPress blog and trying to access the blog itself resulted in a terse, one line error. Oh Oh! Of course, having “been there and done that” I knew what had to be done to get things working again.
First, let me offer a word of advice that can help to limit the effects of a problem like this, should you ever want or need to poke around in your WordPress Theme files. When you are editing these files, you are editing the LIVE files on your existing web site. This means any changes you make take effect immediately. Since some of the theme files effect the Admin pages as well, you can find yourself locked out of your own, now broken, blog.
Whenever you are editing a file, ensure that you have a clean, unedited copy of the file somewhere on your hard drive. Usually, if you downloaded this theme, you will still have the original files there. If you are making a series of changes, you can also keep a local copy of the file as you make changes. This can be down by downloading the file from your web site, or copying and pasting the contents of the file into a text editor on your system. Doing this gives you a fallback point should anything go wrong.
Now, what do you do when things go wrong? First, you should still be able to access your web site via ftp (File Transfer Protocol). This is the same method you used to upload the theme file originally or upload photos, audio and video to your web site. Since it is only the WordPress theme that is broken at this point, using a lower level method of accessing your site, i.e. ftp, should still work fine.
Log into you site using ftp and navigate to the folder that contains your WordPress install. This might be at the the top level of your web site or inside of another folder. In my case, my WordPress installs exist in a sub-folder, so I am looking for something entitled /career/wp-content.
The wp-content folder holds all themes and plugins you have added to your site. Inside of that folder you will find a folder named “themes” and inside that folder you will see sub-folders for every theme you have uploaded to your WordPress site. Locate the folder for the theme you are currently using i.e cutline is the one I am using. Inside of that folder will be all the files that make up that WordPress theme.
Now, you replace the file creating the error with your clean, backup copy of the file. In this particular case, my friend had been editing functions.php, a particularly important file. To repair her site, I renamed the bad file to functions.php.old and then uploaded her original, clean, functions.php file into the same directory.
Immediately the WordPress blog was available again and the changes she had made to functions.php were gone. This then allowed her to acesss the Admin pages for her blog. Now she could attempt to make her changes again, hopefully with better results.
This is a pretty geeky post for most of the readers here, but one take-away is that it can be relatively easy to recover from, what looks like, a major problem with your WordPress blog.
If you are editing your theme files, tread lightly, keep a original, clean copy of the file you are working on, and you will be able to put things a-right on your WordPress blog when something goes wrong.