Set a 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');

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x