Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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???

Tx

share|improve this question

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer
    
Well, I'm in the 10%, I ran the query, but nothing changed. I will see the WP Migrate DB Pro, it sounds great ! –  Juliatzin del Toro Aug 21 at 18:17
1  
what does it list as your url in General Settings area? –  Aris Blevins Aug 21 at 18:54

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

define('WP_HOME','http://localhost/mylocalsite');
define('WP_SITEURL','http://localhost/mylocalsite');

Tx !

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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