Migrating content from one WordPress site to another is easy, thanks to its built-in import/export tool. In this article, we are going to show how to migrate your existing content from one WordPress site to another.
Before everything else, create a backup! This is always necessary if you are going to undertake a sensitive task.
Then, make sure that both the old and the new site are running the latest version of WordPress and that you are not getting any kind of error while browsing both your old and your new websites. Make sure that both of them are running smoothly and are up-to-date. Also, make sure both the source and the destination servers have enough room in their PHP memory limit (see the section “Import File is Too Large” if you’re having problems with this).
If you are encountering errors while browsing your site or if your site is not working as intended, you need to fix it first. If you migrate your site while it’s in an unstable state, you might encounter problems that will give you headaches later on.
However, if you want to migrate your content because you are having problems with your site, then you’ll need to migrate your whole WordPress installation instead and upload it to your new server. It’s not recommended to use the methods here to move your WordPress site to another server, as this article only covers how to migrate your content to an existing WordPress site.
In this step, you are going to get the export file from your source WordPress site.
Login to your source WordPress site’s dashboard and go to Tools > Export.
Once you’re on the Export Page, choose all content and click the “Download Export File” button.
Your browser will start downloading an XML file, named after your domain name and the current date. You will use this file to import your content into the destination WordPress site.
Now that we have the import file ready, it’s time to export it to the new WordPress installation.
In your new site’s dashboard, go to Tools > Import.
Once you are in the import page, find WordPress and click Install Now.
Once the installation is done, click “Run the Importer”.
You will be taken to the “Import WordPress” page. Upload the XML file that you obtained from the source site by clicking the “Choose File” button.
Then click the “Upload File and Import” button.
On the next page, you will choose whether you want to import authors, create a new author for each “old” author, or assign posts of an “old” author to an existing author in the new WordPress site.
It’s up to you what you want to do in this part, but for the “Import Attachments” section, you’ll want to enable the “Download and import file attachments” option.
If you don’t enable it, your images will still be visible on your migrated contents in the new site, but they are linked to your old WordPress site. If your old site goes down, so are all of the images in your imported posts.
Finally, click Submit and wait for the process to finish. You’re done!
If you have a large amount of content to migrate, your XML file might be so large that you can’t upload it or perhaps you can upload a large file but it fails to complete. The example image below shows a WordPress site with a very restrictive maximum file upload size.
At other times, like we said earlier, you have a large enough maximum file upload size, but you’ll be greeted with an error like this one during the migration:
This means WordPress (PHP in particular) wasn’t given enough time to complete the task.
There is another error where you will receive a message that says something similar to “Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate xxx bytes) in /xxx/xxx/public_html/wp-includes/some_plugin.php”. This one means that there isn’t enough memory for WordPress (again, it’s actually PHP) to complete the task.
Thankfully, they can be easily fixed. To increase maximum file upload size, extend the maximum execution time, and increase the memory limit, you can try the following methods:
Note: these may not work in shared hosting environments. If you are using shared hosting service, it’s best to contact your host about this matter. Some of them may even temporarily lift memory limits to allow you to complete your migration.
Method One: Editing php.ini
Find your php.ini file and edit the following to contain the given values:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
memory_limit = 128M
Method Two: Editing .htaccess
Find your .htaccess file that’s located in the root folder of your WordPress installation and add the following code:
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value memory_limit 128M
Either of this method should work. You can also edit the values to decrease them if necessary.
If you are using Nginx, you may also need to increase the “client_max_body_size” value in /etc/nginx/nginx.conf. If you are getting a timeout error and using Nginx, you’ll need to add the following code to nginx.conf:
There are a few errors that you might encounter when migrating content from one WordPress site to another. The most common ones are already outlined above (max execution time, fatal error, etc.). There is one more common error which we’re going to discuss here.
You might encounter an error about a failed import because of an invalid post type. See image below:
This happens if you have a theme and/or set of plugins installed on your source site that’s not installed or active in the destination site. One of the ways to solve this is to have the same theme active for both the source and the destination WordPress site, and/or to install and activate the plugins unique to the source site in the destination site. But if you’re not planning to use the theme or the plugin(s) from your source site in your new site, that’s still okay.
In reality, although the importer will tell you that it failed to import the post or page containing a custom shortcode or post type, it will still actually import it, but they will go straight to the trash where you can easily restore and edit if necessary. Therefore, there’s actually no reason to stress yourself with this error. Just take a look at your trash and all of your posts and pages containing custom shortcode and/or post type will be there.