I have a archive page which is running under https. It doesn't loading any images within the post as all the image urls with http.

It is giving an error like bellow,

Blocked loading mixed active content "http://www.example.com/wp-content/uploads/image.jpg"

How should I avoid that errors and load the images on that page.

I saw in a article simplest way to fix it by converting urls into relative urls.


http://www.example.com/wp-content/uploads/image.jpg -> //wp-content/uploads/image.jpg

Any idea how should I do that ?

  • Has this question been resolved? If so, please click the green checkmark to the answer that helped you the most for our records. Thanks Commented Aug 22, 2016 at 17:37
  • I have marked my answer as the accepted one. Because I was looking for a something that I can deal with each post, not as whole. However it is not explained well in the question(my bad). So most of the answers are correct according to my knowledge. Thanks all. Commented Aug 23, 2016 at 5:21

5 Answers 5


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.


There is a pre-built tool called Search and Replace (recommended in the WordPress.org codex) that you can use to safely edit your database for just this type of change. Whether you choose to use a protocol relative link //wp-content/... or change everything to https to prevent mixed content is still your choice.

The reason for this tool, rather than the easier SQL replace is that data is serialized in the WordPress database and if not taken care of properly can/will be destroyed.

Always make a backup of your database before using this. The toole also gives the option of running a dry run so you can see what tables will be affected before actually performing the task. I personally recommend a dry run (for obvious reasons) and then write down the tables affected. From here, if your server is not exceptionally fast it will be wise to select only a small amount of tables to make changes to at one time so that the process does not hang up and fail. Writing down the affected tables means you can skip the unaffected ones entirely in the live run.

It is not without risk, but if done properly you can run this on a live site. Since you will be changing valid, but not 100% accepted links into valid, and 100% accepted links it should not negatively affect your site so long as you do not give it so high of a workload that the process hangs. Also, mistakes on a live site are bad so don't make those.

If you have a construction area to use, then absolutely use that. But if not, I am saying that it is possible to run this tool on a live site without any trouble. It is by no means fool proof though. I use this tool a lot for moving sites from construction (etc), if this is your first time... expect trouble, always expect and plan for the worst. Make a backup and have it ready.

Note on version 2.? vs 3.?:

If your server is older, then version 2 is likely the one for you. If your server is newer then give version 3 a try. They are both fairly easy to use, but if your server accepts v3 then use that one, it's newer and does everything all one one page which makes things very much more convenient. Try a dry run with version 3 and you should find out if your server can run that version or if you need to use the older version 2.


As the tool should let you know, DO NOT forget to remove this once you are done using it. You don't want this left up for any nefarious character(s) to exploit.


Do a backup before

I propose 2 thing for you:


we have 3 possibility to change your content,

  • permanent tool : this Search & replace for wordpress .
    Its not elegant and it may break your website but I use many time and it works as well.

    I think it can be help you to change database for your whole site in 1 shot.

    It not fix your image into plugin but it can be help at all.

  • Temporary tool : If you aren’t comfortable doing this you can also use the free really-simple-ssl it change you content using add_action, http => https

  • Temporary tool: adding this in your function.php:

    function change_http_into_content( $content ) { $custom_content = str_replace('http://', 'https://', $content ); return $custom_content; } add_filter( 'the_content', 'change_http_into_content' );


Also, don't forget to change your URL into the custom JS, AJAX request and other plugin.


simply used the str_replace function to convert the urls to https

$content = get_the_content();
$content = apply_filters( 'the_content', $content );
$content = str_replace( ']]>', ']]>', $content );
$content = str_replace("http://example.com/", "https://example.com/", $content);
echo $content;

event you can make the relative urls with this way.

  • This is in place of calling the_content()? Note that the real the_content applies a filter (also called the_content) that you are now not calling. In fact that's probably a better way to do this: add a new the_content that makes the search-replace and go back to calling the_content() in your template.
    – Rup
    Commented Aug 10, 2016 at 14:17
  • @Rup I am sorry, I didn't get your point clearly, Can I apply search-replace on the_content() method ? Commented Aug 11, 2016 at 5:20
  • @Rup may be I should add few additional steps as in the edited answer Commented Aug 11, 2016 at 5:25
  • Sorry for the slow reply. Yes, that should fix my concerns. What I actually meant was the 'temporary tool' part of Jean-Philippe's answer: make a new filter and do the search replace in there instead.
    – Rup
    Commented Aug 12, 2016 at 8:56

For Load images with http urls follow below steps:

  1. Go to phpmyadmin export database SQL file.
  2. Open SQL file in text editor.
  3. Find URL like "https://www.example.com/wp-content/uploads/image.jpg".
  4. Replace URL like "http://www.example.com/wp-content/uploads/image.jpg"
  5. Save the file and import updated SQL file.

Hope its helpful.

  • 1
    This is not what I am looking for as I have so many posts within that page Commented Aug 10, 2016 at 12:06
  • @Janith I think he means do a search-replace on the whole database dump in one go, so you will catch everything, but if you want to go down this approach it's far easier to do it directly in the database using SQL.
    – Rup
    Commented Aug 10, 2016 at 14:10
  • No problem, keep the database SQL file backup and replace https tp http. Commented Aug 11, 2016 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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