把下面的代码添加到主题目录中的 functions.php 文件中,之后我们需要做的就是在主题目录下建立一个样式表文件 login.css 文件,把需要的样式写到这个文件即可。
function custom_loginpage_logo_link($url)
{
// Return a url; in this case the homepage url of wordpress
return get_bloginfo('wpurl');
}
function custom_loginpage_logo_title($message)
{
// Return title text for the logo to replace 'wordpress'; in this case, the blog name.
return get_bloginfo('name');
}
function custom_loginpage_head()
{
/* Add a stylesheet to the login page; add your styling in here, for example to change the logo use something like:
#login h1 a {
background:url(images/logo.jpg) no-repeat top;
}
*/
$stylesheet_uri = get_bloginfo('template_url').'/css/login.css';
echo ';
}
// Hook in
add_filter('login_headerurl','custom_loginpage_logo_link');
add_filter('login_headertitle','custom_loginpage_logo_title');
add_action('login_head','custom_loginpage_head');
Via:http://www.chinablogs.org/1825/
2019.09.23更新
PHP7.0+WordPress5.2.3以上版本更新函数修正版:
function custom_loginpage_logo_link($url)
{
// Return a url; in this case the homepage url of wordpress
return home_url();
}
function custom_loginpage_logo_title($message)
{
// Return title text for the logo to replace ‘wordpress’; in this case, the blog name.
return get_bloginfo('name');
}
function custom_loginpage_head()
{
/* Add a stylesheet to the login page; add your styling in here, for example to change the logo use something like:
#login h1 a {
background:url(images/logo.jpg) no-repeat top;
}
*/
$stylesheet_uri = get_template_directory_uri().'/css/login.css';
echo '';
}
// Hook in
add_filter('login_headerurl','custom_loginpage_logo_link');
add_filter('login_headertext','custom_loginpage_logo_title');
add_action('login_head','custom_loginpage_head');
声明:本文采用 BY-NC-SA 协议进行授权,如无注明均为原创,转载请注明转自 你好!刘
本文地址:自定义 WordPress 后台登陆样式
本文地址:自定义 WordPress 后台登陆样式
发表评论