Today, we are going to show you how to import the images from WordPress posts from one website to another.
I’m sure you have tried going to
Export and checking the box to include images and then you see that only the post content gets imported right?
Why the images do not get imported
The reason for this is the export step that causes issues with the image attachment. The WordPress export feature doesn’t include the ‘attachment’ post type unless you select the
All content export option. If you are simply just trying to export posts from one website to another; you will lose your attachments, unfortunately.
If you do a compare from exporting just
All content, the issue is quite obvious. Within the first file; in which we specified we only wanted Published statuses, the attachments are referenced in the posts, but the attachment table is ignored. In the second file, in which we exported All Statuses; the attachment table is included. In other words, the WordPress export function defines Attachment posts as something other than Published. Seems a bit of a pain but fortunately, we have a solution to the problem.
Imagine if you had a blog with 900 posts all with featured images and images within the posts and then there wasn’t a way to import this to a new site? Well, whenever there is a problem, there is always a good solution 😉
How to get your images into your new website…
Okay so if you are only wanting to import/export posts with images, then we recommend using the Auto Upload Images plugin, which can be used even to upload the images after you’ve imported the posts already.
What exactly does this plugin do?
- It looks for image URLs in your posts (imported posts do still have image URLs in them, but they point to the site the content was exported from);
- It then gets those external images and uploads them to the local WordPress uploads directory and adds the images to the media library;
- And finally, it replaces the old image URLs with new URLs.
This process is easy to do and is relatively quick. Once you’ve finished the import, you can remove the plugin once the work is completed.
Step by step process
Step 1: Prepare your export file from the old website
Simply go to
Export and export your posts only.
Step 2: Import your posts into your new website
On your new website, again go to
Import and import the posts you exported. The importer has an option to download and import file attachments, but this won’t work if you’re not migrating all content, so you can simply ignore this option.
Step 3: Install and activate the Auto Upload Images plugin
Download the Auto Upload Images plugin and add it to your plugins folder, or simply search the name in your new website and install and activate the plugin. This will add an option under
Auto Upload Images, but the default settings are all you need.
Step 4: Get the image from your old site into your new site
As of now, the plugin doesn’t have an option to automatically go through your posts and bulk upload all the images. Instead of this, it updates each post individually when you save them. If you have a lot of blog posts on your website, this can be some serious tedious work but we have a solution to that. You can go to your posts overview screen and bulk update your posts.
So what you do here is you select multiple posts and then under
Bulk Actions; choose
Edit and press the
Apply button. Then, without making any adjustments, click the
Update button. Depending on your server you may get a timeout as the process runs, so it’s a good idea to do this maybe 20 to 50 posts at a time.
To change the Pagination, you can click
Screen Options at the top right and change the default value to the value of your choice.
Step 5: Check your posts and deactivate/uninstall the plugin
When all is done you can check your posts and confirm they now reference local images. You then no longer need the plugin and you can safely deactivate and delete it.
Do note, it’s always a good idea to make a backup of your new site first (at least of your site’s database).
The other solution is to use the Export Featured Images plugin. Although the plugin hasn’t been updated in a very long time, it still works! This will allow you to export the featured images from posts or custom post types (CPT’s) by creating a WordPress XML export including the images.
Step by step process
- First export the posts from your old site via
Importthe posts to your new website
- Then use this plugin in your old site and go to
Export Featured Imagesand select post types. This will create a new .xml file for you.
- Now, in your new site go to
WordPress Import. Then select the .xml file which you downloaded in the previous step.
And that’s it, just as simple as that. Now you will have all your posts mapped with featured images, pretty sweet right?
If you have found this helpful, or have a different solution you would like us to mention, please leave a comment below!