How to do it...

Take the following steps to manually generate an error for the purpose of testing this recipe:

  1. Open the wp-config.php file and set WP_DEBUG to false
  2. Add the following code to the functions.php file of your theme:
add_action('init','wpccp_ch9_errors');
function wpccp_ch9_errors(){
if(!is_admin()){
trigger_error('This is custom error', E_USER_ERROR);
}
}
  1. Visit the home page of the site, using a web browser.

Now, you will see the WSoD. Take the following steps to identify and fix the WSoD issue:

  1. Enable Debug mode, using the steps in the Configuring error logs and displaying errors recipe.
  2. Refresh the current URL to see the error on the browser.
  3. Check if the file path is displayed along with the error.

Now, we can take the following steps to check if the issue is caused by the theme:

  1. If the error is showing on a theme file, go to the Appearance | Themes section.
  2. Activate a different theme.
  3. Refresh the previous URL and check if the error is still displaying.
  4. If the error is not displaying, the issue is caused by your theme. Open the theme file mentioned in step 3 of the previous error.
  5. Try to fix the issue, or contact Theme Support to get it resolved.

If the issue is not caused by the theme, we can take the following steps to check if the issue is caused by a plugin:

  1. If the error is showing from a plugin, go to the Plugins menu.
  2. Deactivate the plugin that is causing the issue.
  1. If the error is not displaying, the issue is being caused by a specific plugin. Open the plugin file mentioned in step 3 of the previous error.
  2. Try to fix the issue, or contact Plugin Support to get it resolved.

If the issue is not being caused by the theme or a plugin, we can take the following steps to check for memory-related errors:

  1. If you are seeing a memory error—as shown in the following code snippet—open the wp-config.php file in the code editor. You will get the same error with a different size, depending on the allowed memory size in your server:
PHP: Fatal Error: Allowed Memory Size of 268435456 Bytes Exhausted - 256 MB
  1. Add the following code to increase the memory for WordPress:
define( 'WP_MEMORY_LIMIT', '786M' );
  1. Check the URL with the error again, and see if the memory issue is still displaying. If the error is still displaying, continue increasing the memory until it's resolved.

Now, you should be able to identify the error that is causing the WSoD and take the necessary actions to get it resolved. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset