1. 19
    Replicate a Remote WordPress Site Locally by Importing Content and Logic
    2m 23s

Replicate a Remote WordPress Site Locally by Importing Content and Logic

Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 3 years ago

It is critical for development that your local environment accurately reflects your remote site. In this lesson, you will learn how to import plugins, configuration, and content from a remote to a local WordPress instance.

There are a few steps to do this:

  • Create a fresh install of a WordPress Instance
  • Copy the wp-content folder over to your local site
  • Activate all the necessary plugins that allow the instance to function properly
  • Export and import custom post types
  • Upload the generate content XML file to the local site

Instructor: [0:00] When developing a WordPress instance, you'll often have a remote version of your site and a local version of your site, or maybe you'll have a remote version of the site that you want to develop locally. Here I have the WP content and the content XML from a site that I'm working on.

[0:15] I have an empty fresh WordPress instance. What I want to do is to make this local instance mirror the remote instance we're working with. What we need to do is move our WP content folder and import our content.

[0:31] Here I am with my fresh site. All I'm going to do is I'm going to copy my WP content folder into my public folder, and replace everything that's in it. We look at plugins now. We'll see that we have got lots of plugins here but none of them have been activated. We will activate our plugins.

[0:48] Let's activate WPGraphQL. Let's activate GraphQL Gutenberg. Activate GraphQL for ACF fields, but that's probably going to require having ACF fields installed, which is custom fields.

[0:59] We activate all of these. Don't need FakerPress. Activate REST API blocks. I don't need that. I've got all my plugins installed and activated, and now I'm going to import my content.

[1:09] Import. I'm going to import by WordPress. I'm going to click Install here first. I'm going to run the importer, which is going to get me to the file. I've got this headless WordPress file. Upload File and Import.

[1:21] We've got these options assigned. No Authors, actually, I already exist. Kevin already exists. The rest of them are new, and we can create them. Import Attachments, sure why not? Let's download and import attachments, and submit.

[1:32] You can see, I had two problems, importing the media, and had an invalid post type of chairs. Let's fix the post type of chairs. For post types that are created using the Post Type UI, we need to explicitly export them.

[1:48] We're going to go to Tools. Export. I'm going to select all of the JSONs here on our live remote site and paste it here and import in our local site. Successfully imported. Now we see our Chairs, Custom Types there.

[2:03] If we go back to Tools and Import, run the WordPress importer again, choose our file, again, match this to Kevin, download and import, submit.

[2:13] Now, if we go to Chairs, we can see all of our chairs are there. If we go to Pages, we can see all of our pages are there. If we go to Comments, we can see all of our comments are there.

Patrick
Patrick
~ 3 years ago

In the video you demonstrated how to overcome the issue with a non-existent post type when doing the import. There were, however, still a number of "Failed to import media" messages.

Is there a way to fix these?

Kevin Cunningham
Kevin Cunninghaminstructor
~ 3 years ago

Hi Patrick, Great spot! I should have addressed that in the video.

There are two possible solutions here:

  1. By using Cloudinary - there is a video later in the course that shows how to do that
  2. The error is to do with the change in the URL. I think this deserves an extra video. We need to add some code to our custom theme to override a security feature that stops external URLs to being used in this way.
add_filter('http_request_host_is_external', '__return_true');

This is an example of the code that would allow the import to work without an error. It's worth saying that this line should be removed after the import is complete to re-enable the security feature.

Markdown supported.
Become a member to join the discussionEnroll Today