首先你需要在服务器配置好SSL证书,并且开启443端口,配置成功便可通过https协议访问,但是为了之前的内容兼容https协议,可以参考一下代码实现兼容:
//WordPress SSL
add_filter('get_header', 'fanly_ssl');
function fanly_ssl(){
if( is_ssl() ){
function fanly_ssl_main ($content){
$siteurl = get_option('siteurl');
$upload_dir = wp_upload_dir();
$content = str_replace( 'http:'.strstr($siteurl, '//'), 'https:'.strstr($siteurl, '//'), $content);
$content = str_replace( 'http:'.strstr($upload_dir['baseurl'], '//'), 'https:'.strstr($upload_dir['baseurl'], '//'), $content);
return $content;
}
ob_start("fanly_ssl_main");
}
}
直接将以上代码粘贴到你当前主题中的functions.php文件中即可。
以上代码来自:https://zhangzifan.com/wordpress-ssl-link.html (版权归原作者所有)
本回答被提问者采纳