August 16, 2016 - No Comments!

Solve “mixed content” error on WordPress using https

The HTTPS protocol is the secure version of HTTP, the protocol used to exchange data between your browser and the website you're viewing. https encrypts data during the transit between the server and the client, so you can be safe from attacks like man in the middle. That's great, but then why am I writing this article? 🙂

Are you experiencing the "Mixed Content" error? Let's take a look to this article 🙂

If you're using the https protocol in your WordPress site the mixed content error may be shown on Chrome dev tools. This issue could belong to the images; checking it you could note it uses the http protocol instead of the https one.

Ok, we found the guilty!

To solve this issue you have to use a custom filter, below the function suggested:

function have_https_for_media( $url ) {
    if ( is_ssl() )
        $url = str_replace( 'http://', 'https://', $url );
    return $url;
}
add_filter( 'wp_get_attachment_url', 'have_https_for_media' );

Another way is to use a specific plugin: SSL Insecure Content Fixer.

ssl-insecure-cintenct-fixer-themelovin

Thanks to this plugin you could manage many aspect about the https protocol and its behavior with your WordPress site.

Here you could visit the plugin page on WordPress.org.

If this article is useful for you, how about sharing it?

Cheers

Published by: Themelovin in Code
Tags: , ,

Leave a Reply