The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Change Login Logo to Site Logo

Shared by Moses Cursor Ssebunya · July 25, 2026 · @login_enqueue_scripts

40 views
Back to Snippets

This snippet replaces the default WordPress logo on the login screen with the website’s own site logo. It automatically pulls the logo set under Site Identity, so there is no need to manually paste an image URL into the code.

It also updates the login logo link so that clicking the logo sends users to the website homepage instead of WordPress.org. The logo title text is also changed to the site name, making the login screen feel more branded and professional.

Functionality

This snippet does three main things:

  1. Gets the site logo from the WordPress custom logo setting.
  2. Applies it to the login page using custom CSS.
  3. Changes the logo link from WordPress.org to your website homepage.

Cautions

Make sure a site logo is already uploaded. If no site logo is set, the snippet will not change the login logo.

Use a clean logo with enough width and height. Very small or poorly cropped logos may appear blurry or misaligned.

Avoid adding the same snippet more than once, as duplicate snippets may cause conflicts or repeated styling.

This snippet only changes the login page branding. It does not change the dashboard logo, admin bar logo, or frontend site logo.

add_action( 'login_enqueue_scripts', function () {
	$custom_logo_id = get_theme_mod( 'custom_logo' );

	if ( ! $custom_logo_id ) {
		return;
	}

	$logo_url = wp_get_attachment_image_url( $custom_logo_id, 'full' );

	if ( ! $logo_url ) {
		return;
	}

	$custom_css = '
		.login h1 a {
			background-image: url("' . esc_url( $logo_url ) . '") !important;
			background-size: contain !important;
			background-position: center center !important;
			background-repeat: no-repeat !important;
			width: 100% !important;
			height: 100px !important;
		}
	';

	wp_register_style( 'custom-login-logo-style', false );
	wp_enqueue_style( 'custom-login-logo-style' );
	wp_add_inline_style( 'custom-login-logo-style', $custom_css );
} );

add_filter( 'login_headerurl', function () {
	return home_url( '/' );
} );

add_filter( 'login_headertext', function () {
	return get_bloginfo( 'name' );
} );
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments