WordPress blank page troubleshooting automation

WordPress blank page troubleshooting automation

WordPress blank page troubleshooting automation

It is been a while since we last published a complete tutorial regarding specific WordPress issues. So far we have gone through the installation process, we have learned how to install themes and plugins. Now is the time to start learning more about troubleshooting automation of more complex issues. WordPress blank page is one of those well-known problems and there are a number of reasons for it. 

The so-called white screen of death could be caused by a faulty plugin, broken theme or interferences between the activated extensions. That said, the most logical approach would be to start turning them on and off one by one. So far, so good. We have a course of action, but what happens if we have 30+ plugins and 5 themes?

WordPress blank page troubleshooting automation

Today we will be speaking about blank page troubleshooting automation and more specifically, we would like to present a shell script that would give insights on the problem. It requires the presence of wp-cli. Its main logic is based on simple loops through active plugins and themes. Here is the body of the script and breakdown of its stages:

#Run the script this way: ./blankpagedebug.sh domain.com or domain.com/wptest/ ot test.domain.com (Do not add http; https or https://www)

    if [ -z "$url" ]
    echo "URL is empty"
    exit 1
    test1=$(curl -s -o /dev/null -w "%{http_code}" $url)
    test2=$(curl -s -o /dev/null -w "%{http_code}" https://$url)
    test3=$(curl -s -o /dev/null -w "%{http_code}" https://www.$url)
        if [ $test1 == 200 ]
            echo "The URL is http://$url"
        elif [ $test2 == 200 ]
            echo "The URL is https://$url"
        elif  [ $test3 == 200 ]
            echo "The URL is https://www.$url"
            echo "Unable to detect url"
	    exit 1

initialsizecheck=$(curl -s $real_url | wc -c)
wp db export BlankPageDebugger-BKP 2>&1 > /dev/null
echo -e ' \t '"Backup - BlankPageDebugger-BKP"
echo "Starting turning on/off plugins"

getactiveplugins=$(wp plugin list | grep -v "inactive\|name" | awk '{print $1}')
for i in $( echo "$getactiveplugins")

    wp plugin deactivate $i 2>&1 > /dev/null
    sizecheck=$(curl -s $real_url | wc -c)

    if [ $initialsizecheck == $sizecheck ]
            echo -e ' \t '"No change after stopping $i"
            wp plugin activate $i 2>&1 > /dev/null
            echo -e ' \t '"There is a change after stopping $i"
            wp plugin activate $i 2>&1 > /dev/null

echo "Starting switching the themes"
wp theme list | grep twentynineteen 2>&1 > /dev/null

    if [ $? == 0 ]
        then echo  -e ' \t '"The default twentynineteen theme is present"
        echo  -e ' \t '"The default twentynineteen theme will be installed"
        wp theme install twentynineteen 2>&1 > /dev/null
        touch checkpoint-2019-sg

defaulttheme=$(wp theme list | grep -v "inactive\|name" | awk '{print $1}')
wp theme activate twentynineteen 2>&1 > /dev/null

sizecheck=$(curl -s $real_url | wc -c)
    if [ $initialsizecheck == $sizecheck ]
            echo -e ' \t '"No change after setting up twentynineteen"
            wp theme activate $defaulttheme 2>&1 > /dev/null
            echo -e ' \t '"There is a change after setting up twentynineteen"
            wp theme activate $defaulttheme 2>&1 > /dev/null

if [ -f checkpoint-2019-sg ]
rm -f checkpoint-2019-sg
wp theme delete twentynineteen --force 2>&1 > /dev/null
wp db import BlankPageDebugger-BKP 2>&1 > /dev/null
echo -e ' \t '"Backup restored successfully"

It is important to note that the script needs to run this way:

./blankpagedebug.sh domain.com or domain.com/wptest/ ot test.domain.com

Meaning, we ran the script like any other shell script and pass the domain to it. We do not need to specify a protocol, the script itself will identify it. Here is a breakdown of the code:

  • The first part checks which one of the following http://domain.com, https://domain.com or https://www.domain.com would return 200 OK. Once detected, we put it into a variable to be used later.
  • Before turning the active plugins off and on, we check the size using curl and create a database backup
  • We build a list of the active plugins and start applying the following sequence:
    • Stop the plugin
    • Check the new size of the page
    • Depending on whether there is a change or not, we print a message
    • Reverting the changes
  • We check if twentynineteen is present. If not, we install it
  • We identify the active theme
  • We activate twentynineteen and again check the size
  • We revert the changes and remove twentynineteen if it was installed by us. We also restore the backup generated at the very beginning.

Summary and conclusions

When an unexpected problem happens, logically we have to revert the latest changes. This includes deactivation of the plugins we recently installed or activated. The same applies to the themes. If however, we have a large number of extensions, the whole process may become quite complex and time-consuming. The idea of blank page troubleshooting automation is to prepare a script that would loop through the active extensions and perform certain operations. In over 90% of the case, this simple script gives proper directions about the issue at hand.

WordPress blank page troubleshooting automation
Article Name
WordPress blank page troubleshooting automation
Blank page troubleshooting automation - a shell script to ease the troubleshooting of white screen of death which could be caused by a faulty plugin, broken theme or interferences between the activated extensions. Backup generation and restore. Simple loops through the active extensions.
Publisher Name

Do you want to share your opinion?

Your email address will not be published. Required fields are marked *


We are not industry specific. We are WordPress specific. We work with everyone to help them find solutions with their troubles.
If you show us the problem you are experiencing, we will show you how to fix it. It is that simple.

Reported WordPress issues

  1. How to transfer PHP Mysql based website data in to wordpress
  2. Enqueueing style.scss file Wordpress (problem displaying slick slider)
  3. Wordpress users login restriction
  4. Add ACF Gallery Image Titles to Search
  5. How could I show the menu page children in Wordpress Rest API?
  6. Problem using FT.CREATE command with PHP whereas works in CMD
  7. Deleting a Wordpress user using a custom plugin Hook
  8. Wordpress OOP calling plugin function inside theme
  9. How can I get post list on WordPress (only title ,date and time)
  10. How to increase wordpress site's Timeouts setting on a LNMP server?

WordPress problems we are working on

  1. Adding Schema to Breadcrumbs
  2. Can't access wp-admin with virtual host
  3. Getting MySQL Connection Error: (2054) in Dockerised WordPress
  4. WordPress make all post types and taxonomies work on paged index
  5. How can I get meta field value created in custom taxonomy in WordPress?
  6. Remove automatic nested iframe around an external <script> added in the RawJS element of WPBakery
  7. Merge websites, images double ID’s issue
  8. Why my customized CSS for a wordpress theme is not working from cpanel?
  9. How to add categories meta to Ajax Load More [on hold]
  10. Move shipping address fields to custom page

Resolved issues

  1. tcpdf wordpress error in PHP even tho i followed the tcpdf example 1by1
  2. How do I send an email using NextJS and Wordpress REST API?
  3. Dokan WP - link visibility for user
  4. How to post a form in Wordpress?
  5. Is it possible to add a merge tag for the answer of a field into the description field?
  6. How to redirect multiple files in same directory using nginx?
  7. How to properly get wp_editor() formated value?
  8. wordpress date-field in contact 7 form not pop when you click in the input field
  9. How to add height for content post of wordpress?
  10. Why my viewport based script doesn't add classes
wppotion - powered by persistence and passion