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 Modern WordPress Workflow The Staging Server Migrating from Local to Staging

Jeff Kivett
Jeff Kivett
1,490 Points

How do you make sure the database links are updated when pushing to staging?

This has probably been addressed somewhere in the video already, but I have gone back through it several times and cannot find it. How do you get the links to update (like site-url, etc.) when you do a wordmove push?

1 Answer

There are a number of ways to do this including scripts, plugins or using wp-cli. The method I use is to log into phpMyAdmin and do the following mySQL queries on the database. You should replace wp with whatever prefix you have given your tables:

UPDATE wp_options SET option_value = 'http://example.com' WHERE option_name IN ('siteurl', 'home');

UPDATE wp_posts SET post_content=(REPLACE (post_content, 'http://oldurl.example.com', 'http://example.com'));

Obviously you replace the URLs with your own.