Change Wordpress Post URL

·

1 min read

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');