back home

Change WordPress Post URL

January 24, 2015

Change Author on all posts at once

SELECT ID, display_name FROM wp_users;
UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID;

Update URL Path

-- option table
UPDATE wpia_options SET option_value = REPLACE(option_value, 'http://domain.local', 'https://www.domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wpia_posts SET guid = REPLACE(guid, 'http://domain.local', 'https://www.domain.com');

-- content
UPDATE wpia_posts SET post_content = REPLACE(post_content, 'http://domain.local', 'https://www.domain.com');

UPDATE wpia_posts SET post_content = REPLACE(post_content, 'http%3A%2F%2Fdomain.local', 'https%3A%2F%2Fwww.domain.com');

-- post meta
UPDATE wpia_postmeta SET meta_value = REPLACE(meta_value, 'http://domain.local', 'https://www.domain.com');

-- yoast seo links
UPDATE wpia_yoast_seo_links SET url = REPLACE(url, 'http://domain.local', 'https://www.domain.com');

UPDATE wpia_options SET option_value = REPLACE(option_value, 'https://www.domain.com', 'https://stage.domain.com');
UPDATE wpia_3_options SET option_value = REPLACE(option_value, 'https://www.domain.com', 'https://stage.domain.com');
UPDATE wpia_4_options SET option_value = REPLACE(option_value, 'https://www.domain.com', 'https://stage.domain.com');
UPDATE wpia_5_options SET option_value = REPLACE(option_value, 'https://www.domain.com', 'https://stage.domain.com');
UPDATE wpia_6_options SET option_value = REPLACE(option_value, 'https://www.domain.com', 'https://stage.domain.com');
UPDATE wpia_7_options SET option_value = REPLACE(option_value, 'https://www.domain.com', 'https://stage.domain.com');
UPDATE wpia_8_options SET option_value = REPLACE(option_value, 'https://www.domain.com', 'https://stage.domain.com');

UPDATE wpia_blogs SET domain = REPLACE(domain, 'www.domain.com', 'almond2.domain.com');