Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Robert George
PLUS
Robert George
Courses Plus Student 386 Points

Copy live wordpress site to another wordpress demo site

Hi I have a live wordpress site for a client.

I have made a demo version of the site hosted elsewhere. How do I keep the demo version site up to date with the live site i.e. post and images.

I have tried exporting the posts from the live site and importing on demo site (using wordpress importer/exporter) but the images and links point to live site.

Whats the best way to approach this without having to find/replace urls and fiddling with the site url?

Any ideas please?

Thanks

3 Answers

Sean T. Unwin
Sean T. Unwin
28,690 Points

Are you able to download just the database, either through a plugin like BackUpWordPress or through phpMyAdmin? Then import the database into your test installation and it should work more easily.

Robert George
PLUS
Robert George
Courses Plus Student 386 Points

Ok thanks Sean. What about the media library that is on the live site? What's the best way to copy them across to the demo, bearing in mind the file paths will be different?

Thanks

Sean T. Unwin
Sean T. Unwin
28,690 Points

I found this tutorial on how to copy a live wp site to a local server - http://www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/. Check the section, "Manually Move a Live WordPress Site to Local Server".

The essentials are these:

  • Download the database from live server, either with a plugin or phpMyAdmin.
  • Copy the wp directories from live server with FTP or SSH (in your case perhaps only the plugins and uploads directories.)
  • Assuming you have created the database on the test server and logged into phpMyAdmin, select the database and import the SQL file of the database you grabbed in step 1.
  • Select SQL from the database menu in phpMyAdmin and paste in the following (changing the site URLs as appropriate):
UPDATE wp_options SET option_value = replace(option_value, 'http://www.example.com', 'http://localhost/test-site') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.example.com', 'http://localhost/test-site');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.example.com','http://localhost/test-site');
  • If you have copied the wp-config.php file from the live server, edit the DB_... information.

Ideally, you should be all set now. Best of luck!