10/25/2020
Reading time: 1 mins

Update siteurl and home options in wordpress

When working with Gatsby with WordPress, I had to dump and import my WordPress database multiple times. Either trying out new host, or some data has updated on my local and I need it in production or vice-versa. Every time I need to import SQL dump, I had to manually update the two options in wp_options table, siteurl and home. So instead of updating them manually every time following SQL query updates both at once and I just need to have it in my SQL client’s history so its much easier than going to the table and updating them manually.

UPDATE 
 wp_options 
SET 
 option_value = 
  replace(option_value, 'http://www.oldurl', 'http://www.newurl') 
WHERE 
 option_name = 'home' 
 OR 
 option_name = 'siteurl';
Previous
Gatsby with WordPress
Next
Docker compose update php.ini
© 2024 Anil Maharjan