Although resetting your WordPress installation is not common it is relatively easy to do. It is especially useful for test sites so this post may appeal to the WordPress Theme authors more than most, but it is still very handy to keep bookmarked for future reference. I will continue under the premise this is for a test site although the instructions are much the same for any current WordPress installation.

There are three basic steps to a reset:

  1. Drop all the database tables in the WordPress database.
  2. Re-install WordPress.
  3. Add test data.

That was easy!

Now, let’s go into some more details.

In step 1. above I wrote “Drop all the database tables in the WordPress database”; this is easily accomplished via a straight forward MySQL command:

DROP TABLE `wp_commentmeta`, `wp_comments`, `wp_links`, `wp_options`, `wp_postmeta`, `wp_posts`, `wp_terms`, `wp_term_relationships`, `wp_term_taxonomy`, `wp_usermeta`, `wp_users`;

… or you can use the commonly found phpMyAdmin application if your hosting service provides it via your control panel. Be very careful with this step as it is non-recoverable unless you have a proper backup; all of your existing test site data (posts, pages, etc.) will be lost.

In step 2. above, you simply go to your test site. Follow the prompts to install WordPress. All of the files are still there, the installation just needs to be re-initialized.

Step 3. above can be accomplished in many ways, I would suggest simply importing the Theme Unit Test data as provided by WordPress.

Just follow the link; right-click; and, choose “Save … As…” Different browsers have different terms for this function but it should be clear which one to choose. For example, Firefox uses “Save Link As…”; Chrome uses “Save link as…”; and, Internet Explorer uses “Save Target As…” If you are importing your test data simply go to the Administration Panels and under Tools choose Import. If you have been through this process before it will be quite simple and proceed quickly. If you have not imported data into this site you will be prompted to install the WordPress Importer. Just follow the on-screen prompts in either case.

These are some additional optional actions you will most likely find very beneficial as well:

  • Remove the initial default posts that WordPress creates during the installation process.
  • Re-activate/install these test plugins:
  • Modify your test site default theme to include all the new WordPress 3.1 Post Formats
    • For example, change line 81 in functions.php of  Twenty Ten to:
      add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) );
    • Update the Theme Unit Test posts as neeeded
NB: The plugins listed above each serve important functions for testing purposes. I would suggest the first three as being a requirement for test sites. The two BNS plugins are recommended for testing and for functionality but as I wrote both I may be biased.
    Amendments:

  1. Jan 24, 2011: Edited to add link for Debug Bar in the plugins list.
  2. Mar 22, 2011: Dropped Debogger link.