Export and Import WordPress Posts and Make Attachments Including Thumbnails Show Up

Export and Import WordPress Posts and Make Attachments Including Thumbnails Show Up

I’ve been asked to export articles of one of my company’s website to a new location. While the process of exporting and importing is simple, I ran into an issue where my thumbnail images and media files wouldn’t show up on the destination website. The steps outlined below are what I used to have my pictures and thumbnail images show up.

In short, the main reasons why your media files don’t show up after importing your posts over has to do with disconnects between your files, your posts’ link to the files, and the database. More simply put, you need to make sure that your images’ base url is destination.com instead of originaldomain.com, and the same goes for the links your posts’ content and thumbnail images would use to pull the actual media files from the database. Some people have been able to achieve this sync by changing their permalinks settings to default and then set it back. Others, like me, aren’t so lucky. Need not to lose hope, as there is a way to fix the issue.

 

1) Backup

Always backup both the original site and destination site before you get started. If your hosting company doesn’t offer easy solutions like one-click backup, you can simply go into your server and compress the entire root directory of the original site and destination site. If anything were to happen, you can simply go in and unzip those files to replace the changed sites. For your databases, go into phpMyadmin from your cPanel and export the entire table of your website.

 

2) Download the upload folder of your original website via ftp

Zip up the Upload folder located in WP-Content of your original site’s directory and download it to your computer. Or use filezilla to download the entire folder to your computer, which may take longer.

 

3) Upload the Upload folder to the destination

Upload the aforementioned Upload folder to the WP-Content directory of your destination site. If you have files inside the new website that you would like to keep, it’s best to upload the media files individually. Say that your uploaded files are organized into month and year folders, you may upload only files manually to avoid replacing the entire folders.

 

4) Export your posts from the original website in your WordPress dashboard

Hover over Tools in the left sidebar of your admin panel, select Export. Choose the content that you’d like to have exported. You may narrow down the selection by post types, categories, status, time range, etc. An xml file will be created and downloaded to your computer.

 

5) Import the xml file(s) in website’s WordPress dashboard

Hover over Tools in the left sidebar of your admin panel, select Import. Choose the xml file to upload and hit save/submit. Repeat this step if you have more than one xml file to import. Select the Save and Download attachment option.

 

6) Change urls in your Database’s Post and Post Meta tables

** Log into phpMyadmin to access your website’s database. We will perform search and replace on several locations.

i. Replacing Images Urls and the Urls used to link to images in your pages and posts:

1. Click the “_post” table to view the content inside.

2. Click the “search” button and then click “Find and Replace” once you are inside the search page.

3. On the left field, enter the domain url of your original website: “originaldomain.com”, and on the right field enter the destination domain: “destinationdomain.com”. Select “post_content” and hit Go.

4. You will now preview what changes will be made to the post content. Go to the bottom of the page to click replace.

5. Open the “xxx_post” table again by clicking it on the left sidebar. Next, repeat step 2.

6. Enter “originaldomain.com” on the left field and “destinationdomain.com” on the right, respectively. Select “guid” and hit Go.

7. Repeat step 4

 

ii. Replace the urls in Thumbnail id Columns with new ones

1) Open the xxx_postmeta table by selecting it from the left sidebar

2. Click the “search” button and then click “Find and Replace” once you are inside the search page.

3. On the left field, enter the domain url of your original website: “originaldomain.com”, and on the right field enter the destination domain: “destinationdomain.com”. Select “meta_value” and hit Go.

 

Now it should be all set. You should be able to see all the images, including thumbnails embedded in your posts and pages. The images should also show up in you Media Library the way it used to be on your original website. If you see broken images, try to find out what url the images are pointed to. Search and replace those urls to correct the link between your files and the database.

 

Did you run into any issues with this method? Please leave me a message below with any feedback :).

About The Author

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *