Last active
December 15, 2016 04:09
-
-
Save LouWii/11b7cd3d5ced40366115 to your computer and use it in GitHub Desktop.
Force wordpress embedded content to be https
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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