Table of contents

Introduction

I’m currently working on a website revamp for one of our clients and it’s a full redesign/restructure.

This means that almost everything will be changed, structure, pages, content, media files, etc. Only the articles will remain as they are and will be moved on to the new website.

At this point, I want to move all the articles from live site.com to the staging version that we created at staging.site.com.

Here are the steps that I took in order to move the posts and images correctly.

Export and import posts with WordPress Importer

The easiest thing you can do is use the WordPress Importer. Export the posts from the live site and import them into your staging version. Works like a charm.

WordPress Importer

Now that you did that you notice that there is an issue.

It will import your articles without the media files. All the media files in the articles will still point to your live site. So you’ll have images with src=”site.com/wp-content/uploads/2020/01/image.jpg”.

Move the media files via FTP or cPanel

You should move the media files to your new WordPress install. Do so by using FTP or directly cPanel if it’s on the same server.

The point is to move the whole uploads folder.

Don’t do it file by file, archive the folder on the server, move the archive via FTP and just unpack where you need it to be. It will save you a lot of time.

Search and replace the old URL in the articles

Get the Better Search Replace and run a Dry search first for your live address and see what it returns. In my example, it will be www.site.com.

Your goal is to make the images point to your current address. You will end-up running a search and replace after www.site.com and replace it with staging.site.com in my case.
Yours can be www.site.com and replace with www.newsite.com.
You’re only interested in replacing the main domain because the file structure for the media files will stay the same.

Once you’ve completed this successfully you will see the images from your posts are pointing to the new address on the current install.

Now you will stumble upon another issue: the media files are not displayed in your Media Library.

Add your images into the Media Library

For this step, you’re going to use a plugin called Moving Media Library.

Install this plugin on the first site (from where you want to export), export the JSON format file with this plugin, and import the file on the new site.

This will migrate all details related to images and make them available in your Media Library.

Moving Media Library

It will maintain:

  • ID
  • user ID
  • Date and time
  • Folder structure
  • File name
  • Dimensions
  • Thumbnails
  • Exif data
  • Alternative Text
  • Caption
  • Description
  • Comments

At this point, you’re done with your posts transfer and media files.
You should have all the media files in Media Library and also correctly linked in the posts.

There is an extra step that you can do.

Remove unused Media files

In my example, we’re doing a full revamp of the website. All things will be re-done and the content will change on pages, product pages, any other assets will be replaced.

By moving the whole uploads folder I also moved a lot of files that will not be used anymore on the new site.
I’m interested in keeping only the files that are attached to the blog posts.

Media Cleaner Pro is the tool you’ll want to use for this.
You can go with the free version, but the Pro has a few amazing features.

Once you run the Media Cleaner Pro you’ll be able to get rid of all the extra media files that are not related to articles.

To give you an example, I moved 3.6GB of media files. After I run Media Cleaner Pro and kept only those that are actually used, I ended-up with 0.9GB of media files.

Warning!
Make sure you have a backup before using the Media Cleaner Pro and that you also activate the Trash option in this plugin. Once those files will be deleted they are gone.