Support » Fixing WordPress » Updating Embedded post image links on new url

  • I recently moved my wordpress installation to a new url and got everything up and running fine using this guide:

    But the one problem I have encountered is that all of my images that were embedded in posts have an absolute url to the old site.

    How can I update these image paths without having to go into every post and editing them manually?


Viewing 4 replies - 1 through 4 (of 4 total)
  • Are the images you have embedded part of the post content, like you added them in the post text editor?


    Post Text <img src=”link.jpg” /> More Post Text

    Or did you use an attachment/custom field or something

    They would have been added via the text editor. Most likely using the Upload/Insert functionality.

    How about something like this in your functions.php

    function alter_content($content) {
    	//Set locations
    	$oldDir = '';
    	$newDir = '';
    	$content = str_replace($oldDir,$newDir,$content);
    add_filter('the_content', alter_content);

    This would modify the outputs of the_content before it appears on your blog, so you could change all instances of a URL to another URL say.

    I don’t know if you can automatically update the contents of exisisting posts permanantly from a PHP script, or if there is a better way!

    reading through that link the OP posted….did you go through the search and replace in your database?

    right at the bottom of the page, it talks about images, and also doing a full search of your database for any remaining instances of the old url

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Updating Embedded post image links on new url’ is closed to new replies.