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

Im storing my images on another server and Ive managed to change the urls in the database but I cant seem to change the featured image urls?

I will not be adding any more images so I just want to change the url for all images.

This is the sql I used for normal images

UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="http://www.oldsiteurl.com', 'src="http://newsiteurl.com');


UPDATE wp_posts SET  guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://newsiteurl.com') WHERE post_type = 'attachment';

All the other images are fine except the featured images.

share|improve this question
up vote 2 down vote accepted

The featured image is stored in the *_postmeta table under the _thumbnail_id key. In fact, chances are that you've got a lot of image/media urls in that table, which you haven't changed. The problem is that a number of things are stored in serialized arrays and changing them with SQL as above will (probably) break those arrays. I would suggest using something like Velvet Blues Update Urls.

It looks like you have changed all of your URLs and not just the image/media URLs. Is that what you intended?

Also, you should never change the guid.

NOTE and EDIT: I just noticed an exception for attachment media in the WordPress Codex. I don't remember ever seeing that and I am not sure what that is about and I am not sure what to make of that at the moment.

share|improve this answer
+1 for the guid comment, it is an identifier, not an output. – Wyck Nov 1 '12 at 16:50
Yes I meant to change the GUID it included WHERE post_type = 'attachment'. Thanks, I get the whole feed issue but I still dont really know why I'd want old urls on my site after a domain change or at least a change from local development to live site (I know I should use version control but that confuses the hell out of me). – stemie Nov 1 '12 at 16:54
They aren't URLs, not really. They look like URLs but they aren't. Any globally unique string would work. URLs are co-opted because it is a fairly reliable way to create unique strings. It would be less confusing if it were hashed, or something similar, as hinted at in the Codex by the phrase "some representation of the url". – s_ha_dum Nov 1 '12 at 17:14

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.