Get 6 months free hosting and free domain name with all 18 month web hosting and email plans.

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.

Changing Image URLs using Search Replace DB

Search Replace DB is a free script which makes the process of migrating PHP and MySQL based websites between domain names and web hosts simple. The script is primarily designed for WordPress but also works for most other similar CMS applications.

Search Replace DB searches and replaces content throughout your entire WordPress database, making it a perfect tool for changing image URLs. It also works with WordPress’s multisite and network feature (formerly WordPress MU).

To install. Download Search Replace DB and upload the script to your web root (or the same folder as wp-config.php). Browse to the script’s URL in your web browser and follow the on screen prompts.

Important This file can potentially allow a third-party to access your WordPress site. To prevent misuse delete the file from your web space after use.

Download Search Replace DB on Github.com

Changing Image URLs using SQL

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).

Examples

Update image urls in WordPress – Single site


UPDATE wp_posts SET post_content = replace(post_content, 'http://example.com', 'http://example.co.uk');
UPDATE wp_posts SET guid = replace(guid, 'http://example.com', 'http://example.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://example.com', 'http://example.co.uk');
UPDATE wp_100_posts SET guid = replace(guid, 'http://example.com', 'http://example.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.

Remember to first backup your WordPress database before trying running your SQL query.

Sponsors

Web Hosting – £2.99/mo

Reliable UK web hosting. Free tech support. Trusted UK host since 2004. Free setup. Order online.

http://ecenica.com/

cPanel Hosting – £4.99/mo

Fast cPanel hosting with email. Choice of UK/US servers. 30-day money-back promise. Founded 2004.

http://ecenica.com/

 

Related posts:

 

Tags: , , , , , , , , , , , ,

Share this article

If you found this article useful, please feel free to re-tweet. The Bit.ly Url for this post: http://bit.ly/bsp2rg.

Leave a Reply

You must be logged in to post a comment.

Still need help?

Please login to account and submit a new support ticket.

Copyright

Unless stated, this article is subject to Ecenica Hosting copyright protection. We've worked really hard to bring you this site so before you click copy & paste please take a moment to read our Copyright Notice.

Back to Top