如何将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:3px; 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 { border-radius:1px; }

三、修改logo链接地址

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