WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

WordPress 3.8 is out I have the following code to remove admin bar logo.

 function no_wp_logo_admin_bar_remove() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'no_wp_logo_admin_bar_remove', 0);

However I would like to know how can I replace it with my own logo (upload) and not a dashicon?

share|improve this question

That's controlled by a Dashicon (font icon) and a before statement:

#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {
content: '\f120';
top: 2px;
}

What you'd want is to replace the content call.

Use a built in Dashicon from here: http://melchoyce.github.io/dashicons/

So the smilie would be content: '\f328;`

share|improve this answer
1  
But as the question asks, what about a specialized image that you uploaded? Not a built in icon. – Howdy_McGee Dec 12 '13 at 22:09
1  
Change the content to put an image in. content: url(image.jpg); (The question said 'logo' not 'image' so I didn't presume, and figured they could look up how to use before and content :) ) – Ipstenu Dec 12 '13 at 22:21

You may place your own logo there like this:

function custom_admin_logo(){
    echo '
        <style type="text/css">
            #wp-admin-bar-wp-logo .ab-icon:before{ content:"" !important; }
            #wp-admin-bar-wp-logo .ab-icon{ background-image: url(path/to/your/logo.png) !important; }
        </style>
    ';
}
add_action( 'admin_head', 'custom_admin_logo' );

But, if you wanted to completely remove the corresponding Wordpress menu, including the W logo and its sub-menu stuff and then add your ownlogo, You may do it like this:

function remove_wp_logo( $wp_admin_bar ){
    $wp_admin_bar->remove_node( 'wp-logo' );
}
add_action( 'admin_bar_menu', 'remove_wp_logo', 100 );

function add_my_own_logo( $wp_admin_bar ) {
    $args = array(
        'id'    => 'my-logo',
        'meta'  => array( 'class' => 'my-logo', 'title' => 'logo' )
    );
    $wp_admin_bar->add_node( $args );
}
add_action( 'admin_bar_menu', 'add_my_own_logo', 1 );

Then let some CSS do the remaining part for you:

.my-logo div{
    width: 32px;
    height: 32px;
    background-image: url( path/to/logo.png ) no-repeat;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.