Created
May 10, 2021 20:40
-
-
Save huzaifaarain/ece8782371dd12b64385a9c867c5bb4b to your computer and use it in GitHub Desktop.
Update WP Links In Database After Migration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @oldUrl = "Existing URL" COLLATE utf8mb4_unicode_520_ci; | |
SET @newUrl = "New URL" COLLATE utf8mb4_unicode_520_ci; | |
UPDATE wp_options SET option_value = replace(option_value, @oldUrl, @newUrl) WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET post_content = replace(post_content, @oldUrl, @newUrl); | |
UPDATE wp_postmeta SET meta_value = replace(meta_value,@oldUrl, @newUrl); | |
UPDATE wp_usermeta SET meta_value = replace(meta_value, @oldUrl, @newUrl); | |
UPDATE wp_links SET link_url = replace(link_url, @oldUrl, @newUrl); | |
UPDATE wp_comments SET comment_content = replace(comment_content , @oldUrl, @newUrl); | |
UPDATE wp_posts SET post_content = replace(post_content, @oldUrl, @newUrl); | |
UPDATE wp_posts SET guid = replace(guid, @oldUrl, @newUrl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment