• I am so pissed, I think developers would think when they develop WP that also xampp users build WP sites. And now when I ported the site online, most of my images still show to localhost.

    So i have to go to edit each of 300 articles. I alredy lost so much time to port this site and now this.

Viewing 4 replies - 1 through 4 (of 4 total)
  • many people do this all the time. just do a find and replace on the sql file.

    Thread Starter garfy

    (@garfy)

    how to do that?

    export your database using phpmyadmin. use a text editor to find all instances of localhost and replace them with your new domain name.

    import the file to your site using phpmyadmin.

    Migration Specific SQL Queries
    How to Change SITE URL and HOME URL

    WordPress stores the absolute path of the site URL and home URL in the database. Therefore, if you transfer your WordPress site from the localhost to your server, your site will not load online. This is because the absolute path URL is still pointing to your localhost. You will need to change the site URL and the home URL in order for the site to work.

    Solution:

    update wp_options set option_value =’https://yourwebsiteurl.com’ where option_name=’siteurl’ or option_name =’https://yoursiteurl.com’;
    How to Change GUID

    After you have migrated your blog from the localhost to your server or from another domain to a new domain, you will need to fix the URLs for the GUID field in wp_posts table. This is crucial because GUID is used to translate your post or page slug to the correct article absolute path if it is entered wrongly.

    Solution:

    update wp_posts set guid=replace(guid,’https://oldsite.com’,’https://newsite.com’);
    How to change URL in Post-contents

    WordPress uses absolute path in the URL link instead of a relative path in the URL link when storing them in the database. Within the content of each post record, it stores all the old URLs referencing the old source. Therefore you will need to change all these URLs to the new domain location.

    Solution :

    update wp_posts set post_content= replace(post_content,’https://oldsitename.com’,’https://newsitename.com’)
    Change Image Path Only in Post Content

    By default wordpress store absolute path of the relative images and this create a lots of problem whenever we change our server. SO how to change the image paths stored in the post contents

    Solution:

    update wp_posts SET post_content = REPLACE (post_content, ‘src=”https://www.oldsit.com’,’src=”https://newsite.com’); The above query only change the source of images not the attachments available with that post, So issue the following query also along with the above one.

    UPDATE wp_posts SET guid = REPLACE (guid,’https://www.oldsite.com’,’https://newsite.com’) WHERE post_type = ‘attachment’;
    Update/Change Post Meta

    Post meta is also stored as the same way as your post image and other URLs ie, absolute path, so change them according to new website address

    Solution:

    UPDATE wp_postmeta SET meta_value = REPLACE (meta_value,’https://www.oldsit.com’,’https://www.newsit.com’);

    Please read these commands carefully. Alternatively you can google for sql queried for wordpress administrator.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘This is amazingly bad! Most of my images show path to local host’ is closed to new replies.