I want to manage my WP site in local, then sync it to my git, and then automatically deploy it. In fact, I already have my site in production, and trying to make it work in local. The fact is I can make it work in local, but every link send me to the distant domain : mydomain.com instead of managing localhost.

How should I manage it???



It sounds like you need to update the database to replace the guids and base URL.

I recommend WP Migrate DB Pro to quickly sync two databases. Otherwise you need to run a few SQL statements to find and replace the old domain with the new domain. In PHPMyAdmin run the following statements from the SQL window. Replace old-domain with your exact distant domain, and the new-domain with your complete local address.

UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com', 'http://www.new-domain.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');

Doing so will solve 90% of your link issues.

  • Well, I'm in the 10%, I ran the query, but nothing changed. I will see the WP Migrate DB Pro, it sounds great ! Aug 21 '14 at 18:17
  • 1
    what does it list as your url in General Settings area? Aug 21 '14 at 18:54

Now it is working, I've updated wp-config.php and added 2 lines :


Tx !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.