Site Recovery Tips and Tricks

Something bad is happening on your WordPress site. You try to login and have a white screen, or the entire site has been replaced with error messages. You’re heart is starting to race. Sweat is beading in your face. How will you fix this?

First, calm down. The solution is probably pretty simple. You need to be calm and focused to remember what changes may have led to this. Did you upgrade a plugin, did you install a new plugin, or did you edit your theme functions file? These are the most common issues.

If you are getting a white screen, then please enable debug mode. The white screen is caused by a php error and debug mode will tell you what that error is.

If you already have an error then look and see what it is telling you. Often the errors fit into one of 4 categories. A file is not found, a function is not found, a function is duplicated, or header cannot be modified. These are easy enough to fix.

Genesis Not Found

The Problem:

One issue that comes up regularly in the forums is accidentally activating the child theme without Genesis being installed, or accidentally deleting Genesis (sometimes for a manual upgrade) with the child theme already active. Either of these will result in an error like this

Warning: require_once(%path-to-wordpress%/wp-content/themes/genesis/lib/init.php) [function.require-once]: failed to open stream: No such file or directory in %path-to-wordpress%/wp-content/themes/%child-theme%/functions.php on line 3

The solution:

You will need to access your site via FTP. Once there navigate to your site theme directory. This will vary by host and site setup, but it often looks something like this /public_html/wp-content/themes/. The error code will actually tell you exactly where this is, but typically you will not have access to the first part of the path, but will have access starting around the public_html(or similar) directory.

If you already have Genesis backed up on your computer find that folder. Otherwise, you will need to download the latest version of Genesis from the forums and unzip. Make a note of where the file is and navigate to it in your FTP client.

Make sure the directory you are about to upload is “genesis” spelled exactly like that and that directly inside the directory is “style.css” (along with several other files and directories). If you are using FileZilla (recommended below) on a Windows system then right mouse click the “genesis” folder and select to upload. On Mac you have to activate the context menu by holding ctrl when clicking unless you have a mouse with a secondary button or other means of accessing the context menu.

WordPress Needs Upgrade

The Problem:

When a function doesn’t exist, it is often caused by WordPress being out of date. Always upgrade to the latest version of WordPress. Of course, the simple upgrade isn’t available if this error happens. The error might look something like this:

Fatal error: Call to undefined function add_theme_support() in /%path-to-wordpress%/wp-content/themes/genesis/lib/init.php on line 17

The Solution:

You will have to perform a manual upgrade to WordPress. You will need to access your site via FTP.

First, download the latest version of WordPress at wordpress.org and unzip it. Be sure you remember where it is.

Now find your WordPress installation on your site via FTP. It will have several files and at least 3 folders: wp-admin, wp-content, and wp-includes. First, backup wp-config.php. This is one of your most important files and you don’t want to lose it. Now rename wp-admin and wp-includes to wp-admin-old and wp-includes-old. Find the wordpress folder you unzipped and open it. You should see the same folders are you have on your site. Select everything except the wp-content directory. In FileZilla this can be done quickly with “ctrl+a” then holding “ctrl” and clicking on wp-content to unselect. Now right click and select upload.

You will get a message asking if you wish to overwrite the files. Select yes. In FileZilla you can select to do this for all of the files and to limit it to that queue only. I recommend those settings when answering yes to save time.

After all files are uploaded go to your site dashboard to complete the upgrade. You should get a screen asking if you want to upgrade the database. Do that and the site should be working correctly.

Problems with Plugins

The Problem:

It is always a good idea to disable plugins when upgrading WordPress. Often a plugin will be perfectly stable in one version of WordPress and break another version completely. If you have an error message pointing to a specific plugin you can just disable that plugin otherwise you may have to troubleshoot the site by disabling all plugins. There are a lot of errors that can be caused by plugins, including plugins that define a function already defined in Genesis or the Child theme, or bad coding in the plugin that results in an error. An error message might look like:

Warning: Cannot modify header information – headers already sent by (output started at /%path-to-wordpress%/wp-content/plugins/%plugin-folder%/%plugin-file%.php:119) in /%path-to-wordpress%/wp-login.php on line 337

The Solution:

You will need to access your site via FTP.

If you have a specific fatal error for a specific plugin, then navigate to that plugin. It will be in your plugins directory. This is specific to your host and WordPress installation, but it often looks like /public_html/wp-content/plugins/. Now rename the plugin directory to “directory-name-disabled.” For example, if you have a plugin called “foo” in the directory “foo” then you need to change the directory name to foo-disabled.

If you do not know exactly which plugin is causing the problem, or are troubleshooting to see if plugins are causing the problem, then rename the entire plugins folder to plugins-disabled. If this resolved the problem, then you need to identify the problem plugin. Go to your site and access the plugins page. Make sure everything is disabled then rename your folder back to plugins. Now activate half of your plugins. If the error comes back you know the bad plugin is in that half, if not it is in the other half. Keep activating and deactivating in halves to narrow the error down to a specific plugin. Any time the site goes down you will know there is a bad plugin activated, but you will also have to disable the plugins again via FTP to get your site back.

Error in Child Theme Edit

The Problem:

You were making a change to your theme and now everything is broken. These errors fall into several classes, but the most common are bad php, mixing html with php, and “header already sent.” This last error might look like this:

Warning: Cannot modify header information – headers already sent by (output started at /%path-to-wordpress%/wp-content/themes/%child-theme%/functions.php:119) in /%path-to-wordpress%/wp-login.php on line 337

The Solution:

You will need to access your site via FTP. (Getting repetitive isn’t it?)

For bad php or mixing php with html you need to restore that file from a backup. Ask on the forums how to properly format your php.

For the header already sent error, this is almost always caused by something before the first <?php or after the last ?> in the file. technically you don’t need that last ?> and the child themes are removing that to minimize this type of error. Find the file using the FTP client and right click to “view/edit.” If prompted for a program use notepad. If your file ends with a ?> delete it. If anything is before the first <?php, even empty space such as a space or return delete and then upload the file.

How to Access Your Site Via FTP

To access your site via FTP you will need a few things.

First, a FTP client. I recommend FileZilla. It is free (that should be enough right there), works on any operating system, and has a lot of helpful features.

Second, you must have login credentials for your site. This includes the host, which is often your url, the username, and password. If you do not know any of these, the company you are hosting your site with can provide the details.

Filezilla is easy to use. The default setup shows a split pane (right and left) for your computer and your site. The files and folders on the left are your computer and the files and folders on the right are your site. This can be navigated by typing in the location in the field next to “Local site:” or “Remote site:” or via the folder tree directly under that field. You may also double click on folders to open them in the bottom of the split pane. The “..” directory takes you up one level.

Activating Debug Mode

You will need to access your site via FTP. Once there, go to the directory that WordPress is installed in. You should see the wp-config.php file. This file may already have this line of code.

define('WP_DEBUG', false );

If so just change “false” to “true” and update the file. Otherwise, add this before the stop editing line (I am showing that line in this code example to give you in idea of where to place it, no need to add that line again).

define('WP_DEBUG', true );

/* That's all, stop editing! Happy blogging. */

Once you update the file, you may see quite a few errors. The most important error is the last 1-2 errors, these are the ones being generated just before things break completely.

After you are done fixing your site, be sure to change the “true” back to false.

Comments

  1. Patricia Barry says:

    Thank you so much for this post! I have printed it out and have it by my computer just in case… Please keep your great articles coming – they are invaluable!

  2. Nick, you are the Man!!

    I had two sites disappear on me Friday (ERK!!).

    The “fixes” I found called for hacking the code, but it was Greek to me . . .

    Yours was the most reasonable (and implementable) suggestion I found.

    Thank You, Thank You, Thank You!! You’ve gained another subscriber!!

  3. Harriet Bodkin says:

    Thank you!!!!!!!!!!
    Eternally grateful!

  4. This is just fantastic Nick. Easy to understand. I just got a white page on my site and am going to activate the debugging mode now, didn’t know how to before

    Thanks Nick

    Helen

  5. Thanks for the great info Nick – you saved my site.

  6. Hi Nick!
    I was adding a favicon to my public file following some instructions from another site that I thought directed me to enter some code into the “functions.php” file …href=”favicon.ico>. I did so and saved and then received the error message you now see on the site when you try to access it.
    Parse error: syntax error, unexpected ‘<' in /home/mikel10/public_html/wp-content/themes/corporate/functions.php on line 78
    I removed the code and saved and the error message remains.
    Do I now apply your tips shown on?
    http://designsbynickthegeek.com/tutorials/site-recovery-tips-and-tricks
    Thanks for your assistance
    Mike

  7. Hey there Nick.
    I’ve tried deleting and re-uploading my functions.php file altogether as well as your suggested debugging and I’m still getting this error: Parse error: syntax error, unexpected $end in /home/vietnam/public_html/wp-config.php on line 1

    Any thoughts on what I am doing wrong? I appreciate your time.

  8. thank you so much! Great help. Easy explanation
    Lara

  9. Thanks a ton for utilizing free time to create “Site Recovery Tips and Tricks — Designs By Nick
    the Geek”. Thanks a ton again -Ahmad

  10. GREAT tutorial! You saved my night! I was almost in tears. Thank you. :)

  11. Hi, I found your blog post while searching a fix for my BIG mistake. I had my website set up with home page and no blog and later added blog and made this home page. Things had been working fine till I decided to redesign my site and make a static home page and move blog. Why I changed the setting WP Adress (URL) to http://www.lmstevensphoto.com/blog I do not know. I changed it back immediately when I realized this was not the thing to do. But after this the site broke and now I can not sign into my wp-admin page. I found the wp-conf.php and I do understand to change false to true to make changes and when done change back to true, but I do not know what changes to make to fix. Any ideas??

    Thank you for your time….lisa

    Here are the last few lines you mention in your fix:

    * For developers: WordPress debugging mode.
    *
    * Change this to true to enable the display of notices during development.
    * It is strongly recommended that plugin and theme developers use WP_DEBUG
    * in their development environments.
    */
    define(‘WP_DEBUG’, false);

    /* That’s all, stop editing! Happy blogging. */

    /** Absolute path to the WordPress directory. */
    if ( !defined(‘ABSPATH’) )
    define(‘ABSPATH’, dirname(__FILE__) . ‘/’);

    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . ‘wp-settings.php’);

  12. Thanks! This REALLY helped out today. Almost threw something. Thanks a lot!

  13. I am very much panicking and freaking out right now.

    I made 1 edit to the functions.php file.
    I am trying to reupload the previous version and the file is still not coming back up.

    Please help!

  14. Enjoyed every bit of your weblog. Will read on…