WordPress

Change Image URLs In WordPress

Summary

Learn how to quickly change image URLs in WordPress. Useful if you’ve recently changed your WordPress domain name and your images are no longer showing.

By default, WordPress saves links to images at the time your post or page was published. You can use the following SQL Query to update your posts to use the new URL.

We provide examples for WordPress and WordPress Multisite (formerly WordPress MU).

Make sure you have backup your WordPress database before running any SQL queries.

Examples

Update image urls in WordPress – Single site


UPDATE wp_posts SET post_content = replace(post_content, 'http://www.your-old-domain-name.co.uk', 'http://www.your-new-domain-name.co.uk');
UPDATE wp_posts SET guid = replace(guid, 'http://www.your-old-domain-name.co.uk', 'http://www.your-new-domain-name.co.uk');

Update image urls in WordPress – Multisite (Formerly WordPress MU)

Remember to replace 100 with the ID number of your blog.


UPDATE wp_100_posts SET post_content = replace(post_content, 'http://www.your-old-domain-name.co.uk', 'http://www.your-new-domain-name.co.uk');
UPDATE wp_100_posts SET guid = replace(guid, 'http://www.your-old-domain-name.co.uk', 'http://www.your-new-domain-name.co.uk');

You’ll need someway of running the above SQL queries against your WordPress database.

We recommend phpMyAdmin or installing a WordPress database like WP-DBManager which offers built-in support for SQL queries.

Was this guide helpful?

Need help with this?

Open a ticket and link to this guide so our team can see what you have tried.

View support tickets

Power your business with Ecenica Hosting

Built for WordPress and serious websites. Fast, secure and supported by real people in the UK.

Ecenica hosting services represented by a connected red route across London