How to Replace Old Domain URL in wp_posts Table


I migrated my WordPress website to new domain, so I need to update all image URLs in wp_posts, wp_postmeta, and wp_options table which are still pointing to old domain.

These are the SQL syntaxs to update the tables:

UPDATE wp_posts SET post_content = REPLACE( post_content, '', '' );
UPDATE wp_postmeta SET meta_value = REPLACE( meta_value, '', '' );
UPDATE wp_options SET option_value = REPLACE( option_value, '', '' );
UPDATE wp_posts SET guid = REPLACE( guid, '', '' );

mysql replace


  1. Excellent…thank you. Only addition I would make is also doing a replace on the “guid” if you had revisions on.

    UPDATE wp_posts SET guid = REPLACE( guid, ‘’, ‘’ );

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.