技术成就梦想
努力展现自我

代码美化WordPress登陆页

众所周知,WordPress 登陆页不是很美观,博主也忍了很久了,终于下定决心改一改!

此处省略上图

如果觉得不错的小伙伴,可以自己小小的折腾一下!

废话不多说直接放代码,把下面代码复制到主题文件的 function.php 中:

// 修改默认登录界面的 LOGO 的链接地址为自己网站的地址
function custom_loginlogo_url($url) {
return'https://www.wenzika.com/'; //在此输入你需要链接到的 URL 地址
}
add_filter( 'login_headerurl', 'custom_loginlogo_url');
function custom_register_url($url) {
return'https://www.wenzika.com/'; //在此输入你需要链接到的 URL 地址
}
add_filter( 'login_registerurl', 'custom_register_url');

// 去 LOGO 的 title 文字
function custom_headertitle ( $title ) {
return __( '文字咖 | 实现代码的小清新' );
}
add_filter('login_headertitle','custom_headertitle');

// 添加登录注册界面的背景图片,修改登录,注册框的样式及按钮样式
function custom_loginbg() {
    echo '<style type="text/css">
        body{background: url('.get_bloginfo('template_directory').'/img/login_bg.jpg) center center no-repeat;background-size: cover;}
        #login{position:fixed;right:5%;padding: 2% 0 0;}
        .login #nav{font-size:16px;}
        .wp-core-ui .button-group.button-large .button, .wp-core-ui .button.button-large {height: 35px;width: 100%;margin: 10px auto;line-height: 32px;padding: 0 12px 2px;}
        #backtoblog a{font-size: 16px;}
        .login #nav, .login #backtoblog {text-shadow: none;float: right;margin: 0 31px 0 31px;padding: 16px 0px 0 0px;}
    </style>';}
add_action('login_head', 'custom_loginbg');

//自定义登录页面的LOGO图片
function my_custom_login_logo() {
    echo '<style type="text/css">
        .login h1 a {
            background-image:url('.get_bloginfo('template_directory').'/img/logo.png) !important;
            height: 60px;
            width: 250px;
            background-size: 250px;}
    </style>';}
add_action('login_head', 'my_custom_login_logo');

注意:更换里面的链接和图片地址即可

赞(2) 打赏
未经允许不得转载:鸿华工作室 » 代码美化WordPress登陆页
分享到: 更多 (0)

鸿华网络工作室,收集各类技术类优秀文章,少走弯路学习

NAS数据存储中心鸿华在线音乐

觉得文章有用就打赏一下文章作者

微信扫一扫打赏