When building custom themes client sites it is important to test as many edge case as possible. Theme Unit Test Data is the way to go here and a minimum requirement for any professionally built WordPress theme (in my opinion anyway) If building a theme for the wordpress.org theme repository this will almost certainly be tested. For those using WP-CLI there is a quick and easy way to install and then remove this test data. Naturally, you will need to install and setup WP-CLI before proceeding.
First you will want to backup your current database
wp db export mydatabase.sql
Then reset your WordPress installation. This step is not obligatory as you can import the test data on top of your own data. The --y
flag stands for “yes” in response to the question “Are you sure you want to reset your database?” So make sure you have the old data backed up in case.
wp db reset --yes
Next you will want to import
curl -O https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml
wp plugin install wordpress-importer --activate
wp import ./theme-unit-test-data.xml --authors=create
rm theme-unit-test-data.xml
Here is where you will test you theme. Ideally you should go through and systematically check each of the links which have all sorts of edge cases. Correct any abnormalities and problems with layout. When you are finished you can change back to your old data.
wp db reset --y
wp db import mydatabase.sql
Please note that you will have to provide the --url
flag for some of those wp commands when using multisite. I am happy to answer any questions in the comments.