Change image URLs in wordpress pages & posts

Oct 2

Today I hit a annoying little problem on WordPress that I've seen before, in all fairness I think from reading some of the documentation I may well simply have hit this problem because I'm a man and thought I knew better than reading the instructions, but lets gloss over that for a moment and pretend that this is genuine problem with WordPress and nothing to do with my aversion to instructions! 

If all else fails - read the instructions.

Basically I built an WordPress site on my local server and then moved it to the live server. Being the smart arse I am I just logged into the database and changed the URL in the wp_options table from my test server URL to the live URL. Bingo! - The site is now working.

Unfortunately all the links to my media (images etc) still have links which use my test server URL. Assuming you've found yourself in the same predicament and you have access toto your mysql databasee then this little bit of sql will solve the problem

UPDATE `wp_posts` SET `post_content`=REPLACE(`post_content`, 'http://mytestserver.com/', 'http://myliveserver.com/');

If you've got custom content you might need to do this on those tables too but that should cover most of it for you. Rumor has it that if you don't start hacking around in the database to start with and do this properly then you won't have this problem but...as my mother says "If all else fails, read the instructions"

Recent Comments

Browse by date

Join us on Facebook