Load images with http urls inside https post

It’s a fairly common issue when you update your WordPress site’s URL form HTTP to HTTPS or if you are migrating to a new domain. While a partial solution is to update your WordPress’ home and site URL in your settings:

enter image description here

That doesn’t mean that the new URL structure in your posts will be fixed. This results in some of your pages pointing to your HTTP link instead.

As a quick solution that ensures that all of the URLs for your website are up-to-date, use the following SQL query:

SQL Query

UPDATE wp_options SET option_value = replace(option_value, 'OLD_URL', 'NEW_URL') WHERE option_name="home" OR option_name="siteurl";
UPDATE wp_posts SET guid = replace(guid, 'OLD_URL','NEW_URL');
UPDATE wp_posts SET post_content = replace(post_content, 'OLD_URL', 'NEW_URL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'OLD_URL','NEW_URL');
  • OLD_URL will be replaced with http://example.com (non-HTTP)
  • NEW_URL will be replaced with https://example.com (HTTPS)

Be sure to back up your database before you perform this SQL query in case you run into an issue.

Leave a Comment