1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php网站后台登录背景 wordpress后台登录页面logo/链接/背景修改(自定义)

php网站后台登录背景 wordpress后台登录页面logo/链接/背景修改(自定义)

时间:2019-04-09 19:05:10

相关推荐

php网站后台登录背景 wordpress后台登录页面logo/链接/背景修改(自定义)

wordpress后台登录页面logo链接默认是链接到/,logo图标是一个W图,没有背景图。为了个性化,很多wordpress网站后台都进行了自定义WordPress的登录页面。这个可以在主题的functions.php 添加一些简单的代码来实现自定义修改(不需要插件),即使WordPress版本升级,也不会影响后台修改的效果。

1、自定义wordpress后台登录页面Logo图片

//自定义登录页面的LOGO图片(头像)

function my_custom_login_logo() {

echo '

h1 a { background-image:url('.get_bloginfo('template_directory').'/logo.png) !important; }

';

}

add_action('login_head', 'my_custom_login_logo');

1

2

3

4

5

6

7

//自定义登录页面的LOGO图片(头像)

functionmy_custom_login_logo(){

echo'

h1 a{background-image:url('.get_bloginfo('template_directory').'/logo.png)!important;}

';

}

add_action('login_head','my_custom_login_logo');

以上代码中的/logo.png为图片地址,可改为其他图片格式如.jpg等。上传到网站根目录所用的主题下。

2、自定义wordpress登录页面LOGO链接为网站首页链接

//自定义登录页面logo链接为首页链接

add_filter('login_headerurl', create_function(false,"return get_bloginfo('url');"));

1

2

//自定义登录页面logo链接为首页链接

add_filter('login_headerurl',create_function(false,"return get_bloginfo('url');"));

3、自定义登录界面LOGO链接为任意(其它)链接地址

//自定义登录界面LOGO链接为其他链接链接

function custom_loginlogo_url($url) {

return '/blog/1/'; //修改URL地址

}

add_filter( 'login_headerurl', 'custom_loginlogo_url' );

1

2

3

4

5

//自定义登录界面LOGO链接为其他链接链接

functioncustom_loginlogo_url($url){

return'/blog/1/';//修改URL地址

}

add_filter('login_headerurl','custom_loginlogo_url');

4、很多wordpress网站后台背景图每天都在自动更换(即每天一图),这个主要是WordPress登录页面使用必应(Bing)背景美图作为登录页面背景。

如果你使用bing美图作为WordPress登录页面背景图,以上1、2、3可以不用添加了。以下代码logo图标为favicon.ico这个你也可以修改为其他头像、图标等,上传到你网站根目录就可以了。logo图标链接为网站首页链接,背景图就是bing美图了。

//wordpress bing美图自定义登录页面背景

function custom_login_head() {

$str = file_get_contents('/HPImageArchive.aspx?idx=0&n=1');

if (preg_match("/(.+?)/ies", $str, $matches)) {

if(git_get_option('git_loginbg')){

$imgurl = git_get_option('git_loginbg');

}else{

$imgurl = '' . $matches[1];

}

echo '';

}

}

add_action('login_head', 'custom_login_head');

add_filter('login_headerurl', create_function(false, "return home_url();"));

add_filter('login_headertitle', create_function(false, "return get_bloginfo('name');"));

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

//wordpress bing美图自定义登录页面背景

functioncustom_login_head(){

$str=file_get_contents('/HPImageArchive.aspx?idx=0&n=1');

if(preg_match("/(.+?)/ies",$str,$matches)){

if(git_get_option('git_loginbg')){

$imgurl=git_get_option('git_loginbg');

}else{

$imgurl=''.$matches[1];

}

echo'#reg_passmail{display:none!important}body{background:url(' . $imgurl . ');background-repeat:no-repeat;background-position:topcenter;background-attachment:fixed;background-size:cover;width:100%!important;height:100%!important;}.login label,a{font-weight:bold;}.login-action-register #login{padding:5%00;}.login-action-register h1{display:none;}.login p{line-height:1;}.login form{margin-top:10px;padding:16px24px16px;}h1 a{background-image:url(' . home_url() . '/favicon.ico)!important;width:32px;height:32px;-webkit-border-radius:50px;-moz-border-radius:50px;border-radius:50px;}#registerform,#loginform{background-color:rgba(251,251,251,0.3)!important;}.login label,a{color:#000!important;}';

}

}

add_action('login_head','custom_login_head');

add_filter('login_headerurl',create_function(false,"return home_url();"));

add_filter('login_headertitle',create_function(false,"return get_bloginfo('name');"));

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。