Skip to content

Instantly share code, notes, and snippets.

@fkobon
Forked from ashhitch/update-urls.sql
Created September 5, 2022 11:22
Show Gist options
  • Save fkobon/795d7e5a7ae5202055d1f2bcce0264ef to your computer and use it in GitHub Desktop.
Save fkobon/795d7e5a7ae5202055d1f2bcce0264ef to your computer and use it in GitHub Desktop.

Revisions

  1. @ashhitch ashhitch renamed this gist Jan 31, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @ashhitch ashhitch renamed this gist Jan 31, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @ashhitch ashhitch created this gist Jan 15, 2014.
    19 changes: 19 additions & 0 deletions Update site URL in Wordpress
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    /* update all post permalinks */
    update wp_posts
    set guid = REPLACE(guid, 'http://www.oldsite.com', 'http://www.newsite.com')
    where guid LIKE '%http://www.oldsite.com%';

    /* update all post content */
    update wp_posts
    SET post_content = REPLACE(post_content, 'http://www.oldsite.com', 'http://www.newsite.com')
    where post_content LIKE '%http://www.oldsite.com%';

    /* update all post meta */
    update wp_postmeta
    SET meta_value = REPLACE(meta_value, 'http://www.oldsite.com', 'http://www.newsite.com')
    where meta_value LIKE '%http://www.oldsite.com%';

    /* update all options */
    update wp_options
    set option_value = REPLACE(option_value, 'http://www.oldsite.com', 'http://www.newsite.com')
    where option_value LIKE '%http://www.oldsite.com%';