我正在使用wordpress 4.1并尝试在没有任何插件的情况下更改 domain.com/wp-admin 中的徽标,但在DOM文件中找不到任何解决方案 我已经在使用这种方法,但仍然无法正常工作,我错过了一些东西
此代码 WP-登录:
wp_admin_css( 'login', true );
/*
* Remove all stored post data on logging out.
* This could be added by add_action('login_head'...) like wp_shake_js(),
* but maybe better if it's not removable by plugins
*/
if ( 'loggedout' == $wp_error->get_error_code() ) {
?>
<script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script>
<?php
}
/**
* Enqueue scripts and styles for the login page.
*
* @since 3.1.0
*/
do_action( 'login_enqueue_scripts' );
/**
* Fires in the login page header after scripts are enqueued.
*
* @since 2.1.0
*/
do_action( 'login_head' );
if ( is_multisite() ) {
$login_header_url = network_home_url();
$login_header_title = get_current_site()->site_name;
} else {
$login_header_url = __( 'http://sumayku-design.web.id/' );
$login_header_title = __( 'sumayku-design' );
}
和风格 :
.login h1 a {
background-image: url(http://www.blog.sumayku-design.web.id/wp-content/uploads/2015/01/petra-truss-logo.png);
-webkit-background-size: 84px;
background-size: 84px;
background-position: center top;
background-repeat: no-repeat;
color: #999;
height: 84px;
font-size: 20px;
font-weight: normal;
line-height: 1.3em;
margin: 0 auto 25px;
padding: 0;
text-decoration: none;
width: 84px;
text-indent: -9999px;
outline: none;
overflow: hidden;
display: block;
}
这应该是对的。
但是有一些选择:
- (浏览器)缓存仍然具有旧图像。
- 您更改了错误的 CSS。css 在/login.min.css 中,但也有 css/login.css
但是,与其编辑默认的css,不如添加一个新的CSS文件(放在页面中另一个文件之后),并在那里放置这样的东西来覆盖登录图像:
.login h1 a {
background-image: url(../images/newlogo.jpg);
}
通常我使用下面编写的代码,并且在更改管理员徽标时工作正常:
function custom_login_logo() {
echo '<style type="text/css">
h1 a { background-image: url(/wp-content/uploads/2014/10/logo.png) !important;
background-size: 100% 100% !important;
background-position: center center !important;
height: 82px !important;
width: 359px !important;
margin-left: -14px !important;
}
</style>';
}
add_action('login_head', 'custom_login_logo');