一、将下面代码加到主题 functions.php 模版文件的最后:
<?php
function custom_login() {
echo '<link rel="stylesheet" tyssspe="text/css" href="' . get_bloginfo('template_directory') . '/custom_login/custom_login.css" />'; }
add_action('login_head', 'custom_login');
?>
二、在所用主题中新建一个名称为:custom_login 的文件夹,并在其中新建:custom_login.css 及制作好的网站 LOGO:logo.png 也放进去。
三、将下面代码添加到 custom_login.css 中:
/** 背景及字体 **/
HTML,body.login{
background:#f2f2f2;
font: 14px 'Microsoft YaHei', Arial, Lucida Grande, Tahoma, sans-serif;
}
/** 去掉链接下划线 **/
html a{
text-decoration: none;
}
/** 登录DIV **/
#login {
background:#fff;
border: 1px solid #ccc;
width:400px;
margin: 40px auto 0;
padding: 10px 10px 20px 10px;
border-radius:5px;
box-shadow:0 4px 10px -1px rgba(200, 200, 200, 0.7);
}
/** 替换logo **/
.login h1 a{
background: #fff url(logo.png) no-repeat center;
width:400px;
}
/** 提示 **/
.updated, .login .message {
background:#fff;
border: none;
text-align: center;
}
/** 表单 **/
.login form {
box-shadow:none;
border: none;
}
#loginform, #registerform, #lostpasswordform{
background:transparent;
border:none;
}
/** 按钮 **/
.button-primary,.submit .button-primary,#login form .submit input {
width:83px;
height:25px;
font-weight: bold;
border:none;
}
另外,也可以将下面代码添加到主题 functions.php 模版文件中,直接将样式写在其中。
function new_custom_login_logo() {
echo '<style type="text/css">
//YOUR CSS Code Here
</style>';
}
四、修改 logo 链接地址
function custom_loginlogo_url($url) {
return 'https://api.liaooo.cn';
}
add_filter( 'login_headerurl', 'custom_loginlogo_url' );