# Your Site Icon in Place of the WordPress Logo in the Admin Bar

> Replaces the WordPress logo menu in the admin bar with your Site Icon linking to the dashboard, a simple branding touch for client sites.

- Type: PHP
- Runs: Run everywhere
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: branding, admin-bar, white-label
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/admin-bar-site-logo/

## Code

```php
add_action( 'admin_bar_menu', function ( $admin_bar ) {
    $admin_bar->remove_node( 'wp-logo' );

    $icon = get_site_icon_url( 32 );
    $name = get_bloginfo( 'name' );
    $mark = $icon
        ? '<img src="' . esc_url( $icon ) . '" alt="" width="20" height="20" style="width:20px;height:20px;border-radius:3px;vertical-align:middle;margin-top:-3px">'
        : '<span style="display:inline-block;width:20px;height:20px;line-height:20px;text-align:center;border-radius:3px;background:#2271b1;color:#fff;font-weight:600">' . esc_html( strtoupper( mb_substr( $name, 0, 1 ) ) ) . '</span>';

    $admin_bar->add_node( array(
        'id'    => 'wpide-site-logo',
        'title' => $mark . '<span class="screen-reader-text">' . esc_html( $name ) . '</span>',
        'href'  => admin_url(),
    ) );
}, 11 );
```

## Notes

Set a Site Icon under Settings > General first; without one the site name's first letter is shown.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Your Site Icon in Place of the WordPress Logo in the Admin Bar" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
