It doesn’t always happen, but you may need to reset your WordPress site. This could be due to troubleshooting, testing, or development reasons. Resetting your WordPress site restores it to its default state – no posts, pages or categories, no activated plugins or themes.
There are many ways to reset a WordPress site. One way to do that is to reinstall WordPress from scratch. However, there are other ways to as well. We may use a plugin, use a command line tool, or do a manual reset. For this tutorial, we will learn all these three. We will be resetting a WordPress site using the WP Reset, a free and easy to use plugin. We will also use WP-CLI, a command line tool for WordPress. Lastly, we will also learn how to do a manual reset.
With that, we can now proceed.
(Optional) Backing up a WordPress Site
This section is optional but important.
Prior to resetting a site, you should back it up. Backing a site up will allow you to retain a copy of the site, ready to be restored if needed. We recommend using UpdraftPlus. It’s free, easy to use, and packed with features. If you find that you need more features than UpdraftPlus offers, consider using UpdraftPlus Premium.
Using WP Reset to Reset a WordPress Site
In this section, we will learn how to reset a WordPress site using WP Reset.
Installing and activating WP Reset
First, we have to install the WP Reset plugin and activate it. We will do that through the admin dashboard
From the admin dashboard, hover over “Plugins” then click “Add New”. You will be redirected to the “Add Plugins” page.
Type “WP Reset” inside the “Search plugins” textbox.
Install WP Reset by clicking “Install Now”
Click “Activate” to activate WP Reset.
Once that is done, we can now proceed to resetting your site.
Resetting a WordPress Site with WP Reset
From the admin dashboard, hover over “Tools” then click “WP Reset”.
This will redirect you to the “WP Reset” page.
Scroll down to the “Site Reset” section.
(Note:” Site Reset” is a type of reset and the only one that WP Reset offers. It deletes all WordPress tables, both default and custom. Consequently, it also will delete all WordPress data stored in those tables – pages, post, settings, etc. Another way of putting it is that it deletes database-based WordPress content (for the rest of the article we will call these “content”). However, it does not delete the site’s files. Plugins, themes and uploaded media are unaffected. You may want to learn more about what “Site Reset” does. If you need more reset options, consider upgrading to WP Reset Pro. This will unlock two more reset options – Options and Nuclear. For this tutorial and in most common scenarios, the”Site Reset” option will be sufficient)
Click on the options you need.
Type ‘reset’ in the “Type in ‘Reset'” field.
Click “Reset Site” after.
You will be prompted. Click on “Reset WordPress” to proceed resetting.
Upon a successful reset, you will be notified that the site has been successfully reset.
Here’s a closer look at the message:
We’ve successfully reset the site.
WP Reset Additional Tools
WP Reset also comes with additional tools. To see them, click on the “Tools” link in the WP Reset dashboard. Each tool comes with a brief description of what it does. These tools help in resetting WordPress configurations and deleting WordPress files.
For instance, there is a “Delete Themes” tool which allows you to delete all the theme in your current WordPress site.
There is also a tool for most of the plugins in the WordPress site.
Lastly, there is also a tool cleaning the WordPress site’s “upload” folder.
Browse the page to learn more about the tools and to find other tools you may need.
(Optional) Using WP Reset’s Snapshots
WP Reset also allows users to create snapshots of a WordPress site. a snapshot is the state of a system in a specific point in time. In the context of WordPress sites, a snapshot is a record of the WordPress site’s database – in a point in time. The data in the database defines the state of the WordPress site, since this is where the site’s contents and settings are stored. This state can be restored if needed. (Note: Snapshots do not affect a WordPress site’s files.)
It should also be noted that a snapshot is not a backup. Click here to learn more about the differences.
Creating a snapshot with WP Reset
To create a snapshot with WP Reset Go to WP Reset’s “Snapshots” page. Scroll down to the “User Created Snapshots” section.
Click on “Create Snapshot”
You will be prompted to enter a snapshot name. Enter a name. For this tutorial, we will call the snapshot “Snapshot1”. Click “Create snapshot” to create the snapshot.
You will see a “Snapshot created” message once the snapshot is created.
We’ve now created a snapshot
Recovering a site’s snapshot with WP Reset
To recover a snapshot go to WP Reset’s “Snapshots” page. Scroll down to the “User Created Snapshots” section. Look for the snapshot you will use. For this tutorial, the tutorial we will be using is “Snapshot1”
Click on the arrow inside the “Actions” button. This will show several options. Click on “Restore snapshot”.
A window will appear asking if you want to proceed. Click on “Restore snapshot”
You will see a “Snapshot has been restored” message.
We’ve restored the site to a snapshot.
Deleting a WP Reset Snapshot
WP Reset Snapshots can also be deleted. To do this, go to WP Reset’s “Snapshots” page. Scroll down to “User Created Snapshots” section. Once there, click on the arrow inside the “Actions” button. Choose “Delete snapshot”
A window will appear asking if you want to proceed. Click “Delete snapshot” to delete.
You will see a “Snapshot has been deleted” message.
We’ve deleted the snapshot.
Using WP-CLI to Reset a WordPress Site
In this section we will be learning how to use WP-CLI to reset a WordPress site.
WP-CLI is as the official documentation says:
WP-CLI is the official command line tool for interacting with and managing your WordPress sites.
It lets users manage their WordPress sites through the command line.
Before you can use WP-CLI, you need to download and install it. The installation is platform specific so be sure to check this page for more details.
We can execute different actions using WP-CLI commands.
A WP-CLI command has this structure:
The “wp” before command is necessary.
To reset a site we will be using the “wp db” command. The command:
performs basic database operations using credentials stored in wp-config.php.
To be specific, these credentials.
These commands cannot work on their own. For them to work, we have to execute their subcommands.
A subcommand is a command plus a specific keyword and additional options if applicable.
The format of a WP-CLI subcommand is:
wp command subcommand --additionaloptions
To reset the WordPress site, we will be using the “wd bd reset” subcommand which:
Removes all tables from the database.
The documentation further states that the subcommand:
Runs DROP_DATABASE and CREATE_DATABASE SQL statements using DB_HOST, DB_NAME, DB_USER and DB_PASSWORD database credentials specified in wp-config.php.
WIth that, we now know what command (and to be more specific, subcommand) to execute to reset a WordPress site.
Using the “wp db reset” subcommand to reset a WordPress site
To use the command, you have to execute them at the root directory (or subdirectory) of the WordPress site you will be resetting.
Navigate to the root of the WordPress site to be reset. In our example, we will use the subcommand on “C:\xampp\htdocs\wp-test” since that is the root of the WordPress site we will be resetting. Once there, open a command window in the directory. To do that, press and hold “Shift” and then right click. A menu will pop up. Click on “Open command window here”.
Once open, type “wp db reset” in the command-line. You will be asked to confirm. Type “y” to reset.
If the reset was successful, you will be shown a message.
Accessing the site, will redirect you to the WordPress installation page
We now know how to reset a WordPress site using WP-CLI.
Using the “wp site empty” subcommand to reset a WordPress site.
There is another subcommand we can use to remove all WordPress content – “wp site empty”. This subcommand deletes all WordPress content but allows the settings of the WordPress site to be kept. As the documentation states, the subcommand:
Truncates posts, comments, and terms tables to empty a site of its content. Doesn’t affect site configuration (options) or users.
As an example, we will use the subcommand to remove all WordPress Posts in the example site.
In the image below we can see that there are numerous WordPress posts.
We will open a command-line window in the site’s root directory. We will type “wp site empty” inside the command-line.
Type “y” to empty the site of its contents. A message that the site was emptied will be shown.
In the image below, we can see that the site has been emptied.
We now know how to empty a WordPress site using WP-CLI.
Manually Resetting a WordPress Site
In this section, we will learn how to manually reset a WordPress site.
All we need to do is drop the database’s tables and then run the “install.php” inside the site’s admin dashboard.
Dropping the tables of the WordPress site’s database.
We will be using phpMyAdmin to drop all the tables of the site’s database.
Run phpMyAdmin on a browser. Once there, click on the “Databases” tab.
Once there, click on the database the site is using. In this example, it will be the “first-wp-db” since the that is the database the site we will be resetting is using. It will redirect to the database’s Structure page.
Once there, click the “Check all” checkbox at the bottom. Choose the “Drop” option at the “With select” dropdown menu You will be prompted to continue. Click “Yes” to drop all tables.
Dropping and Creating the WordPress site’s database
Dropping the WordPress site’s database
Alternatively, we could have just dropped the site’s database. in this example, we will be dropping the “first-wp-db” database since it is what our WordPress site is using.
Recreating the WordPress site’s database
To create a database, enter the old database’s name in the “Database name” field. Click “Create” after.
(Note: If you decide to give your created database a different name you would have to edit the “wp-config.php” file found in your site’s root directory.
Running the install.php script
After dropping the tables or dropping a of the database, run the “install.php” script on your browser.
This should be familiar as this is how WordPress is installed.
Choose a language.
Fill the necessary fields then click “Install WordPress” This will reinstall the WordPress site.
Finally, the “Success” page will be shown.
We now know how to manually reset a WordPress site.
In this tutorial, we learned different ways to reset a WordPress site. We learned how to do this using WP Reset, using WP-CLI and doing a manual reset. Now that we’ve learned those we are now ready to apply what we’ve learned to real world scenarios. We can now reset a WordPress site should we need to.