将WordPress登录页面背景图设为必应美图

必应美图,每天一张,不出家门看遍世界,感受大自然的魅力。

那么如何将必应美图设置为登陆界面的背景?

将以下代码加入当前主题的functions.php文件当中:

//调用bing美图作为登录页背景图
function custom_login_head(){
$str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1');
if(preg_match("/<url>(.+?)<\/url>/ies",$str,$matches)){
$imgurl='http://cn.bing.com'.$matches[1];
echo'<style type="text/css">body{background: url('.$imgurl.');width:100%;height:100%;background-image:url('.$imgurl.');-moz-background-size: 100% 100%;-o-background-size: 100% 100%;-webkit-background-size: 100% 100%;background-size: 100% 100%;-moz-border-image: url('.$imgurl.') 0;background-repeat:no-repeat\9;background-image:none\9;}</style>';
}}
add_action('login_head', 'custom_login_head');
《将WordPress登录页面背景图设为必应美图》版权归逐凨所有
转载请保留原文链接:https://izhizu.com/wordpress/118.html
THE END
分享
二维码
< <上一篇
下一篇>>