WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently I have deployed 2 sites from my local development area to the live site and ran into some issues when importing the posts. The reference link for attachments still points to my localhost for some of the attachments. I would like to remove the development sites but removing them will pull down the reference to some of the live attachments.

I was curious if anyone knows best practice for resolving this issue. I know all the attachments are on the live server just the reference is missing. I used custom fields with full paths for most these posts.

I have an idea of just editing the db directly to remove the reference to the files.

Thanks in advance for all help,


share|improve this question

If I read correctly it's not just your custom meta but also your attachments (all images, videos, media, etc)

Do you have phpmyadmin? Do an export of the database and do a search for "http://yourlocalhostaddress.com" and replace with "http://yournewwebaddress.com" save and reimport

You can also do this with mysql but I'm very new to mysql commands and don't want to tell you the wrong one.

Again as Ethan mentioned always back up your database first.

share|improve this answer

As I read your question, it looks like you are using custom fields to store full paths. I think the cleanest way is to run a SQL query to cleanup your custom fields.

UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'MYOLDPATH', 'MYNEWPATH')

Always backup your DB before you run an Update Query

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.