Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Change the WordPress login logo without a plugin

Put your own logo on the WordPress login page with two Snipfire snippets. Unlike the Login Logo plugin, they use the logo already set in your theme.

What Login Logo does

Login Logo replaces the WordPress logo on the login page with a login-logo.png file you put in your wp-content folder. The plugin on WordPress.org

What the snippet does the same

  • Your logo replaces the WordPress logo on the login page.
  • The logo links to your home page, with your site's name, instead of WordPress.org.
  • There is nothing to set up once it is on.

What's different

  • The plugin uses a PNG file you upload to wp-content. The snippet uses the logo set in your theme (Site Logo, or Customizer > Site Identity). If your theme has no logo, nothing changes.
  • The plugin can use a different logo for each site and network on multisite. The snippet uses each site's own theme logo.
  • The snippet scales the logo to at most 320 pixels wide and 120 pixels tall.

When to keep the plugin Keep the plugin if you want a login logo that is different from your site logo.

The snippet: Your logo on the login page

Shows the logo set in your theme (Site Logo or Customizer > Site Identity) on the login page instead of the WordPress logo.

PHP
<?php

add_action(
	'login_enqueue_scripts',
	static function () {
		$logo_id = (int) get_theme_mod( 'custom_logo' );
		if ( ! $logo_id ) {
			$logo_id = (int) get_option( 'site_logo' ); // Block themes.
		}
		$logo = $logo_id ? wp_get_attachment_image_src( $logo_id, 'medium' ) : false;
		if ( ! $logo || empty( $logo[1] ) ) {
			return;
		}
		$height = (int) min( 120, round( 320 * $logo[2] / $logo[1] ) );
		wp_add_inline_style(
			'login',
			sprintf(
				'.login h1 a{background-image:url("%s");background-size:contain;background-position:center;width:100%%;max-width:320px;height:%dpx;}',
				esc_url_raw( $logo[0] ),
				max( 40, $height )
			)
		);
	}
);

Notes, where it runs and what it was tested with

The snippet: Login logo links to your site

The logo on the login page links to your home page, with your site’s name, instead of WordPress.org.

PHP
<?php

add_filter( 'login_headerurl', static fn() => home_url( '/' ) );
add_filter( 'login_headertext', static fn() => get_bloginfo( 'name', 'display' ) );

Notes, where it runs and what it was tested with

Switching from the plugin

  1. Install the snippet in Snipfire (it arrives switched off).
  2. Deactivate Login Logo.
  3. Switch the snippet on. Snipfire checks the code and test-loads your site first.
  4. Check the page it affects, then delete the plugin.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.