Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have moved a theme from local to live and the image URL's are showing my live localhost default url instead of the current live url.

Any idea's on why and how to fix this?

The site is live at universitycompare.com, then jump to university guide and you will see my problem - incase you wanted something live to look at it.

The images are being located as a default URL under http://universitycompare.com:8888/imagepathurl/etc

Just want to revert all the media back to the original which should be: http://universitycompare.com/imagepathurl/etc

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Using Wordpress plugin -

Search And Replace

This is simple Wordpress plugin, Does database query to replace any content. This plugin can be used to replace a string ( say - localhost:8888 ) with a new one ( domain.com ) .


Direct updating MySQL Database -

Or, If you've access to MySQL Server you can simply replace the old domain with new one using this SQL Query

UPDATE wp_posts 
SET post_content = REPLACE
(
    post_content,
   'http://universitycompare.com:8888/imagepathurl/etc',
   'http://universitycompare.com/imagepathurl/etc'
);

( Note - Above code is not tested, Backup your database before using it )


Using Wordpress Filter -

Here's simple filter to used in functions.php, Simply replaces the old domain name with new one

add_filter( 'the_content', 'wpse64204_img' );
function wpse64204_img( $content ) {

    $old_url = '/universitycompare.com:8888/';
    $new_url = 'universitycompare.com';

    $new_content = preg_replace($old_url, $new_url, $content);
    return $new_content;
}

( Note - This does not updated the Database )

share|improve this answer

Your Answer

 
discard

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.