如何修改WordPress登录页面

如何将WordPress的logo替换为自己网站logo,并改变其外观,打造一个个性化的登录页面。
一、将下面代码加到主题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.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;   
}  
复制代码

 

三、修改logo链接地址

function custom_loginlogo_url($url) {
return 'http://defcon.cn';
}
add_filter( 'login_headerurl', 'custom_loginlogo_url' );

 

另外,也可以将下面代码添加到主题functions.php模版文件中,直接将样式写在其中来自定义logo。

function new_custom_login_logo() {
        echo '<style type="text/css">
            //YOUR CSS Code Here
        </style>';
}

 

posted on   剩余价值  阅读(340)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示