Skip to content

Instantly share code, notes, and snippets.

@LouWii
Last active December 15, 2016 04:09
Show Gist options
  • Save LouWii/11b7cd3d5ced40366115 to your computer and use it in GitHub Desktop.
Save LouWii/11b7cd3d5ced40366115 to your computer and use it in GitHub Desktop.
Force wordpress embedded content to be https
//Add this code to the end of the functions.php file of your wordpress theme
// This forces images urls and links of your website to be displayed with https
function force_https_the_content($content) {
if ( is_ssl() )
{
$content = str_replace( 'src="http://my-domain.tld', 'src="https://my-domain.tld', $content );
$content = str_replace( 'href="http://my-domain.tld', 'href="https://my-domain.tld', $content );
}
return $content;
}
add_filter('the_content', 'force_https_the_content');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment