The regular way to delete a WP Staging staging site is to use the delete button from the Sites / Start page
But sometimes it may happen that you do not have the option to delete the staging site. For example, this can happen if you’ve activated the WP Staging setting “Remove Data on Uninstall” and uninstalled WP Staging before deleting the staging site by using the intended delete button.
In that case, WP Staging loses the connection to the staging site and you need to delete the testing site manually by the steps below.
The other reason why you might do not have the option to delete a staging site is when the cloning process has been interrupted accidentally. In that case, data from an unfinished created website maybe still in the database and subfolder of your production site. For the moment you need to delete that data manually as well.
Another reason for a missing staging site is when you restored your website with a prior back up which has been done before creating the staging site. So this backup would miss the connection data to the staging site.
Delete Database Data in Tables
To delete the staging site log in to your database with the software PHPMyAdmin or adminer and delete all tables which do not belong to one of your existing staging sites. For instance, that can be all tables that start with the prefix wpstg1_
or wpstgbak_
Instead of deleting all tables one by one you can use the SQL query below which creates a new query that you can use to delete all tables at once:
SELECT CONCAT('DROP TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE 'wpstg0_%' or TABLE_NAME LIKE 'wpstgtmp_%' or TABLE_NAME LIKE 'wpstg0_%' or TABLE_NAME LIKE 'wpstg1_%' or TABLE_NAME LIKE 'wpstg2_%' or TABLE_NAME LIKE 'wpstg3_%' or TABLE_NAME LIKE 'wpstg4_%' or TABLE_NAME LIKE 'wpstg5_%' or TABLE_NAME LIKE 'wpstg6_%' or TABLE_NAME LIKE 'wpstg7_%' or TABLE_NAME LIKE 'wpstg8_%' or TABLE_NAME LIKE 'wpstg9_%' or TABLE_NAME LIKE 'wpstg10_%' or TABLE_NAME LIKE 'wpstg11_%' or TABLE_NAME LIKE 'wpstg12_%' or TABLE_NAME LIKE 'wpstg13_%' or TABLE_NAME LIKE 'wpstg14_%' ;
This creates a new SQL query that deletes all tables which begin with the prefixes,wpstg0_
wpstg1_
and wpstg2_
DROP TABLE DATABASENAME.wpstg1_options;
DROP TABLE DATABASENAME.wpstg1_postmeta;
DROP TABLE DATABASENAME.wpstg1_posts;
In the future, WP Staging will be able to clean up those unused tables automatically but for now, this little extra work is needed.
Delete Files
Also, check if the plugin has been created a subfolder in the root path of your production site. You need to delete that folder as well:
After doing that, nothing is left and the staging site has been deleted completely.