WordPress的URL地址http转https后资源文件无法正常显示的解决办法
WordPress的URL地址http转https后资源文件无法正常显示的解决办法:
1.找到当前运行的主题所在目录如:wp-content/themes/wordstar/ 打开functions.php文件,在
1 |
require get_template_directory() . '/inc/main-funtions.php'; |
之前加入如下代码
1 2 3 4 5 6 7 8 9 |
add_filter('script_loader_src', 'agnostic_script_loader_src', 20,2); function agnostic_script_loader_src($src, $handle) { return preg_replace('/^(http|https):/', '', $src); } add_filter('style_loader_src', 'agnostic_style_loader_src', 20,2); function agnostic_style_loader_src($src, $handle) { return preg_replace('/^(http|https):/', '', $src); } |
wordpress管理后台修改找到wp-includes/functions.php打开它,在
1 |
require( ABSPATH . WPINC . '/option.php' ); |
后加入
1 2 3 4 |
add_filter('script_loader_src', 'agnostic_script_loader_src', 20,2); function agnostic_script_loader_src($src, $handle) { return preg_replace('/^(http|https):/', '', $src); } |
如果您对C#游戏开发感兴趣,可以扫下面二维码加入我们的QQ群来一起学习交流
原创文章,转载请注明本文链接地址(违者必究):WordPress的URL地址http转https后资源文件无法正常显示的解决办法