Friday 24 June 2016

How to Fix Common WordPress Errors


 if you’re seeing an error on your WordPress site, don’t panic. In this post, we cover some of the most common WordPress errors and how to fix them.

The Dreaded WordPress Syntax Error
How to Fix Common WordPress Errors 
This issue normally happens when a code snippet is added to a functions.php file or a custom plugin/theme is uploaded to WordPress. The error would look something like:
Parse error - syntax error, unexpected $end in /site/domain/wp-content/themes/child-theme/functions.php on line 82
The way to fix this syntax error is to look for the “missing bracket”.  So its either you opened a bracket and never closed it or there is some other unexpected “important” characters like:
 ) ] } ; , :

The Frustrating 500 Internal Server Error

This error is SO frustrating because it never gives enough details to figure out what is going on with the error.  It is like your server just gives up and quits to go take a nap and leaves you to figure out the issue.
So here are a few things to try that 95% of the time does the trick.
  1. Check the PHP memory limit in either the php.ini file or by adding the following line to your wp-config.php file.
    define(‘WP_MEMORY_LIMIT’, ‘64M’);
  2. The second area to check is a messed up .htaccess file. First, make sure you save a copy of the current .htaccess file by simply renaming it. Then test the site and see if it comes back. If it does… congrats you fixed it. Now go back to the Permalinks settings of WordPress and simply hit Save. That will generate a new valid .htaccess file for your site.
  3. If those don’t work. You may have to start deactivating plugins to see if you can figure out if the internal server error is a plugin issue.
  4. If those don’t work, try reuploading the wp-admin folder and the wp-includes folder from a fresh download of the wordpress.zip file.
  5. If you arrived at this fifth step, ask your hosting provider for help. ðŸ™‚

Error Establishing a Database Connection

This is a pretty easy two step process. The first step is to simply check and make sure the login and password information in the wp-config.php file are still valid and correct. If they are, the issue could be that the database server with your hosting company is just being unresponsive. So check their support or status page to see if that’s the case. Finally, it means the database is corrupted and its time to use BackupBuddy to restore the database.

Scary White Screen of Death

WordPress has its own version of Microsoft’s Blue Screen of Death… except WordPress’ version is simply a whiteout of your screen… nothing is there.  9 times out of 10 it is because of the PHP memory of your site being exhausted and you need to increase the PHP memory as described above.  If increasing the PHP memory limits doesn’t fix the issue you will need WordPress to supply more information for you.
We can turn on a better error report by setting up these two lines in the wp-config.php file.
error_reporting(E_ALL); ini_set(‘display_errors’, 1);
define(‘WP_DEBUG’, true);
This will replace the blank screen with errors, warnings, and other notes of information that we can use to google search a fix. ðŸ™‚
Side note: Before going to all the trouble with a white screen of death fix… try emptying your cache if you use a caching plugin and that can also fix the issue.

404 Errors for Posts

There are times that WordPress might return 404 errors for posts even though you know the posts exists.  This normally results from the Permalinks going wonky.  (Someone accidently switch permalinks and switched back and something went wrong.)  To fix this the easiest method is to go back to the Permalinks settings page and re-save the setting.

Missing Buttons on the Visual Editor

If you customize the visual editor, either through plugins or code snippets, there may be an issue where buttons go “missing”.  Most of the time this is a javascript error so to fix this try these 3 steps.
  1. Clear the browser cache (yes, your browser will cache javascript files)
  2. Replace all the TinyMCE scripts with fresh files.  This means replacing the folder wp-includes/js/tinymce with a fresh copy.
  3. Add this line to your wp-config.php to help track down an issue.

define(‘CONCATENATE_SCRIPTS’, false);
Hopefully the buttons should return after going through each of these steps.

Tired Memory

We’ve all seen these errors:
Fatal error: Allowed memory size of 234987 bytes exhausted (tried to allocate 98273422 bytes) in /site/domain/wp-includes/plugin.php on line 2349
When this happens you simply need to adjust the php.ini file of your server or add a line into yourwp-config.php file.
define(‘WP_MEMORY_LIMIT’, ‘64M’);

Why can’t I upload anything with WordPress?

9 times out of 10 it is a simple directory permissions issue on your server.  Try setting the “directories” of the /uploads/ folder in the wp-content/ folder to 744.  (if that doesn’t work try 755.  Next you need to set the permissions for the FILES in the upload folder to 644.  
Remember that BackupBuddy (and iThemes Security) can analyze the permissions settings of your server and will recommend proper settings when needed.

WordPress Takes a LONG Coffee Break

You might visit your website and find this message on the front page:
Briefly unavailable for scheduled maintenance. Check back in a minute.
Huh… you weren’t aware of any maintenance.  This is actually a built in protection of WordPress that occurs when an update is taking place.  Before an update occurs, WordPress adds a hidden file called .maintenance to your server (in the same area as the .htaccess file.  If for some reason the update finished and WordPress forgot to remove the .maintenance file you will see that screen.
So, you simply delete the .maintenance file and your site is back.

Login Page Refreshing and Redirecting Cycle

If you ever experience the problem of attempting to login to your WordPress site with the correct username and password and it simply redirects back to the login page.  This normally is because thesite_url and home_url settings fields in the WordPress settings page are incorrect.  To correct this issue, try the following steps:
  1. Clear the cookies in your browser to reset the cookies that are used for login authentication in WordPress.
  2. Try replacing the .htaccess file by renaming the old one and then visiting the Permalinks settings area and re-saving to generate a fresh .htaccess file.
  3. Hard code the site and home url into the wp-config.php file
    define(‘WP_HOME’, ‘http://domain.com’);
    define(‘WP_SITEURL’, ‘http://domain.com’);
There are many more issues you might run into during your time with a WordPress site but the most important thing to remember is to always have a current and valid backup of your site.  WithBackupBuddy as your WordPress partner you don’t have to worry when you run into that unexpected issue because you’ll always have a working version of your WordPress site that can be restored.
-ithemes

1 comment:


  1. Very helpful Post!!! This is the first time I have read a post like this. Find Career tips here.

    WordPress White Screen of Death

    ReplyDelete