Skip to content

Instantly share code, notes, and snippets.

@bryanwillis
Forked from rosemarystanley/wordpress_move
Created January 11, 2016 01:36
Show Gist options
  • Save bryanwillis/9ef99e95ac76de340659 to your computer and use it in GitHub Desktop.
Save bryanwillis/9ef99e95ac76de340659 to your computer and use it in GitHub Desktop.
SQL query to move Wordpress to new URL
UPDATE `wp_options` SET `option_value` = REPLACE (`option_value`,'http://old/url', 'http://new/url') WHERE `option_value` LIKE '%http://old/url%';
UPDATE `wp_postmeta` SET `meta_value` = REPLACE (`meta_value`,'http://old/url', 'http://new/url') WHERE `meta_value` LIKE '%http://old/url%';
UPDATE `wp_posts` SET `post_content` = REPLACE (`post_content`,'http://old/url', 'http://new/url') WHERE `post_content` LIKE '%http://old/url%';
/* WP Gallery Plugin */
delimiter //
DROP PROCEDURE IF EXISTS update_wp_gallery_slides;
CREATE PROCEDURE update_wp_gallery_slides()
BEGIN
IF EXISTS (SELECT * FROM `wp_gallery_slides`) THEN
UPDATE `wp_gallery_slides` SET `link` = REPLACE (`link`,'http://old/url', 'http://new/url'), `image_url` = REPLACE (`image_url`,'http://old/url', 'http://new/url') WHERE `image_url` LIKE '%http://old/url%' OR `link` LIKE '%http://old/url%';
END IF;
END//
CALL update_wp_gallery_slides();
/* Login Redirect Plugin */
delimiter //
DROP PROCEDURE IF EXISTS update_wp_login_redirects;
CREATE PROCEDURE update_wp_login_redirects()
BEGIN
IF EXISTS (SELECT * FROM `wp_login_redirects`) THEN
UPDATE `wp_login_redirects` SET `rul_url` = REPLACE (`rul_url`,'http://old/url', 'http://new/url'), `rul_url_logout` = REPLACE (`rul_url_logout`,'http://old/url', 'http://new/url') WHERE `rul_url` LIKE '%http://old/url%' OR `rul_url_logout` LIKE '%http://old/url%';
END IF;
END//
CALL update_wp_login_redirects();
/* Revolution Slider Plugin */
delimiter //
DROP PROCEDURE IF EXISTS update_wp_revslider;
CREATE PROCEDURE update_wp_revslider()
BEGIN
IF EXISTS (SELECT * FROM `wp_revslider_slides`) THEN
UPDATE `wp_revslider_slides` SET `params` = REPLACE (`params`,'http://old/url', 'http://new/url') WHERE `params` LIKE '%http://old/url%';
UPDATE `wp_revslider_static_slides` SET `params` = REPLACE (`params`,'http://old/url', 'http://new/url') WHERE `params` LIKE '%http://old/url%';
END IF;
END//
CALL update_wp_revslider();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment