自定义 WordPress 后台登陆样式

网站APP, 转自点点 11 年前 回复

,

把下面的代码添加到主题目录中的 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');
支付宝打赏微信打赏

如果此文对你有帮助,欢迎打赏作者。

发表评论

欢迎回来 (打开)

(必填)