I transferred a website from localhost to a live domain. The images are not showing up and all pages link to localhost. How can I change this? Please guide. Thanks.

3 Answers 3


You can either use the SQL query or use the Velvet Blues WordPress plugin. Via SQL

UPDATE wp_posts SET post_content = REPLACE(post_content, 'localhost/test/', 'www.yourlivesite.com/');

This will resolve the broken links and missing images issue.

  • The query did worked. 307 rows were affected but I still do not see any of the images getting displayed.
    – user2238
    Commented Sep 30, 2014 at 7:44
  • are you using any gallery plugin or something ? if yes may be the images you want to use will be stored in that gallery plugin's table. so if this is the case then you want to do the same replace on that table
    – Zammuuz
    Commented Sep 30, 2014 at 7:49
  • Have a look at: this as there are a few other places to update your WP links as well (not just for images) Also check any CSS with image locations that are not relative.
    – Aravona
    Commented Sep 30, 2014 at 7:52

You will have to change URLs in your code too. There are many ways to do that but this is the one I use and find it very easy to work with. Also it does not damage PHP serialized strings or objects.

  1. Download this searchreplacedb2 script from github.
  2. Upload searchreplacedb2.php to root of your website (where wp-config.php is)
  3. Access this from browser. http://your-domain.com/searchreplacedb2.php
  4. Click submit button and check Load DB connection values from WordPress?
  5. It will load DB details from wp-config.php but if it does not or fill incorrect values then fill correct db details
  6. Click Submit DB details
  7. Let it select all tables in WordPress database. Check on Leave GUID column unchanged? and click on continue.
  8. Fill old URL in first input field and new url in second field. And click `submit search string'
  9. That's it. On next page it will confirm the changes. All urls has been fixed now.

If there are no changes at your live site in regards to the localhost one, meaning it is an absolute copy I'd suggest you to replace your whole DB contents. It's much easier than doing search and replace. The easiest way is with WP Migrate DB plugin. You just need to export your DB with the plugin and define your new URL and files destinations for your live server. After you've exported the database into a file you can import it with phpMyAdmin or whatever tool there is in your hosting panel for database administration. Be ware though, that this is an absolute Database replacement, and importing the whole DB from your localhost WordPress site would change every single data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.