While working on WordPress sites, many times we require bulk data to test the performance of different plugins and themes. This is because the plugins and themes may be performing exceptionally well when there are only a few posts available on our site. As the number of posts increases, some plugins find it difficult to handle large volumes of data and this might negatively affect the performance. We need to take care of this issue during the initial stages of site design itself.
While working on BlogTriangle, I also faced this issue. Let us, for example, consider the related posts section on this website. The related posts will load quickly when there are only a few posts available. But I was not sure how it would be when the number of posts in this blog increases and reaches three-digit figures. These kinds of performance tests could be done in our staging environment. But we cannot test the performance of the blog without proper data. I have tried and tested different mass pages/posts creator plugins that could create bulk data. But none of them worked up to my expectations. Finally, I came across some publicly available datasets that we could import to our blog to create hundreds of WordPress posts and comments instantly.
In this blog, I will cover the step by step procedure to bulk add posts and comments in WordPress for testing. First, we need to install a plugin WordPress Importer.
Formerly WordPress supported this import functionality without requiring any additional plugin. But we need to install this plugin separately for the latest versions of WordPress. This plugin has more than 4 million installations and is created by WordPress itself. Once this plugin installed and activated we can see the import option as shown below.
Under the import settings, we could see several options such as Blogger, Tumblr, etc. These options help us to import data from these different platforms to our blog. Here we are going to select the Run Importer option under WordPress to import data.
WordPress allows uploading WordPress eXtended RSS (WXR) files to create the required data. Now, what are these files? The name WXR may seem to be a bit scary and confusing to even programmers. This is nothing but a simple file with information about posts, custom post types, pages, comments, categories, tags, users, etc in XML structured format. For those without knowledge about XML files, it is enough to understand that this file has data that WordPress system could understand and convert into posts, comments, tags, etc.
Now let us see how we could get this data. Although we have options to generate this data online by using tools such as data generator it would be really time-consuming and requires knowledge of WordPress data structure. So let us use some readily available data sources.
For this tutorial, I have used a sample data source from here. Download this data source in zip format and then unzip it. WordPress allows a maximum file size of 512 MB for upload. The file we have downloaded is just about 5 MB. Now let us upload this data using the upload file and import option under Import WordPress as discussed before.
Now a new screen will appear with options to assign the posts from the XML file to an existing user or to create a new user for the sample data. In this tutorial, I have assigned all our posts to the existing blogtriangle user as shown below.
The process of uploading and importing data is time-consuming as this file will create 1000 posts and 2000 comments. It took me about 6-7 minutes for the process to complete. Once the process is complete a confirmation screen will appear. Now let us navigate to our posts section. We could see 1000 newly generated posts as shown below.
If we navigate to the comments section we could see over 2000 newly created comments.
There are many WordPress data sources available like the one mentioned in this blog. The process of using these data sources to bulk add posts and comments in WordPress are exactly the same. Hence based on our requirements we could get enough sample data for testing. Once our testing is done we have to bulk delete all these data or reset our WordPress blog.