Set a Dashboard Logo

This snippet of code will allow you to customize your WordPress dashboard logo.

This snippet of code will allow you to customize your WordPress dashboard logo.

The two functions below need to be added to your theme’s functions.php file. Note: before doing so, be sure to change “mysite” to your preferred name.

function mysite_customize_register( $wp_customize ) {
	$wp_customize->add_setting( 'mysite_dashlogo', array( 'default' => '' ) );
	$wp_customize->add_control(
		new WP_Customize_Image_Control(
			$wp_customize,
			'dashlogo',
			array(
				'label'       => __( 'Dashboard Logo', 'mysite' ),
				'section'     => 'title_tagline',
				'settings'    => 'mysite_dashlogo',
				'description' => 'Set a logo for the admin bar',
			)
		)
	);
}
add_action( 'customize_register', 'mysite_customize_register' );
function mysite_admin_dashlogo( $wp_admin_bar ) {
     $dashlogo = get_theme_mod( 'mysite_dashlogo');
     if( !empty( $dashlogo ) ) { ?>
         
     <?php }
 }
 add_action('admin_bar_menu', 'mysite_admin_dashlogo');

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1 other subscriber