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


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

( 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 )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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