Reputation: 291
I want to create a custom logo so I need change the default logo of the wordpress logo.
Upvotes: 5
Views: 9503
Reputation: 4934
Here is the function (inserted into functions.php) which will correctly override the admin logo:
/**
* customize the admin logo that appears in the header
* http://www.wpbeginner.com/wp-themes/adding-a-custom-dashboard-logo-in-wordpress-for- branding/
* @author Paul Bredenberg
*/
function htx_custom_logo() {
echo '
<style type="text/css">
#wp-admin-bar-wp-logo > .ab-item .ab-icon {
background-image: url(' . get_bloginfo('stylesheet_directory') . '/assets/images/dashboard-logo.png) !important;
background-position: 0 0;
}
#wpadminbar #wp-admin-bar-wp-logo.hover > .ab-item .ab-icon {
background-position: 0 0;
}
</style>
';
}
//hook into the administrative header output
add_action('admin_head', 'htx_custom_logo');
HTH!
Upvotes: 5
Reputation: 912
Sunny's answer only overrides the icon of the item. If you want to delete the item completely you can do this:
function htx_custom_logo() {
echo '
<style type="text/css">
#wpadminbar #wp-admin-bar-wp-logo>.ab-item {
display:none;
}
</style>
';
}
//hook into the administrative header output
add_action('admin_head', 'htx_custom_logo');
Upvotes: 0
Reputation: 11
I did few arrangement:
- support the fullscreen mode
- use the favicon of the site so it is automatically customized for multisites, and you can put some default image if there is no favicon)
I put "width: 12px" to have a square shape for the favicon cover background
If it can help someone here is the code :
function my_custom_admin_logo() {
echo '
<style type="text/css">
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {content:none;}
#wpadminbar #wp-admin-bar-wp-logo > a {
background-image: url(' . get_site_icon_url() . ') !important;
background-size: cover !important;
}
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon {width: 12px;}
@media screen and (max-width:782px){ #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon {width: 46px;} }
a.edit-post-fullscreen-mode-close.has-icon {
background-image: url(' . get_site_icon_url() . ');
background-size: cover;
}
.edit-post-fullscreen-mode-close.has-icon > svg > path { display: none;}
</style>
';
}
//hook into the administrative header output
add_action('wp_before_admin_bar_render', 'my_custom_admin_logo');
Upvotes: 1
Reputation: 21
Change your dashboard logo to custom logo with this code:
add_action('admin_head', 'my_custom_logo');
function my_custom_logo() {
echo '
<style type="text/css">
#header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }
</style>
';
}
Upvotes: 0
Reputation: 1
function my_login_logo() { ?>
<style type="text/css">
body.login div#login h1 a {
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/site-login-logo.png);
padding-bottom: 30px;
}
</style>
Upvotes: 0