Users & Login PHP Beginner

Custom Login Page Logo, URL, and Styles

Replace the WordPress logo, link, and tooltip on the login page with your own brand, and add custom CSS to match your site's colour scheme, a standard white-label step for client site handoffs.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 30 lines
add_action( 'login_enqueue_scripts', function (): void {
	$logo  = get_stylesheet_directory_uri() . '/images/logo.svg';
	$brand = '#6F58CA'; // Your brand colour.
	?>
	<style>
		#login h1 a {
			background-image: url('<?php echo esc_url( $logo ); ?>');
			background-size: contain;
			background-position: center;
			width: 100%;
			height: 80px;
		}
		.login input[type="text"]:focus,
		.login input[type="password"]:focus {
			border-color: <?php echo esc_html( $brand ); ?>;
			box-shadow: 0 0 0 1px <?php echo esc_html( $brand ); ?>;
		}
		.wp-core-ui .button-primary {
			background: <?php echo esc_html( $brand ); ?>;
			border-color: <?php echo esc_html( $brand ); ?>;
		}
	</style>
	<?php
} );

// Link the logo to your homepage instead of WordPress.org.
add_filter( 'login_headerurl', fn () => home_url( '/' ) );

// Use your site name as the logo's text.
add_filter( 'login_headertext', fn () => get_bloginfo( 'name' ) );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

The WordPress login page greets every administrator, editor, and client with a large WordPress logo that links to wordpress.org. For agency-delivered sites and plugin developers handing off client sites, this is a branding miss, the login page is the first thing a client sees when they access their site’s backend, and it should reflect their brand or yours, not WordPress’s. This snippet covers the three standard white-label customisations: logo, link destination, and basic colour theming.

What the code does

Place your logo file at /images/logo.svg in your theme directory, or adjust the path to wherever your logo lives.

The Logo

The login page logo is an <h1><a> element with the WordPress logo set as a CSS background image. The snippet overrides that background image with your own logo via the login_enqueue_scripts action, which fires on the login page before styles are output. SVG is the recommended format, it scales cleanly at any size and the file is typically small.

The height of the logo container is set to 80px in the snippet. Adjust this based on your logo’s aspect ratio, taller logos need more height, horizontal logos may need less. The background-size: contain and background-position: center combination scales the logo to fit within whatever dimensions you set without cropping.

login_headerurl

By default, clicking the logo on the login page opens wordpress.org in a new context. The login_headerurl filter changes the link destination to your homepage. Clients who click the logo will be taken to the front end of their own site, which is almost certainly what they’d expect, rather than to an external WordPress marketing page.

login_headertext

The tooltip text shown when hovering the logo link defaults to “Powered by WordPress”. The login_headertext filter replaces it with the site name from WordPress settings. This is a minor detail but it completes the white-labeling, no WordPress branding remains visible on the login page after these three changes.

Colour Customisation

The inline styles in the snippet target the login form’s input fields and primary button. The focus ring colour and button colour are set to a purple that matches the Nahnu Plugins brand, replace #7c3aed and #6d28d9 with your own brand colours. Keep the button hover state slightly darker than the default state to maintain visual feedback.

Going Further

For a fully custom login page, custom background, custom layout, or a completely redesigned form, consider using the login page customisation as a starting point and adding more CSS to hide the WordPress footer text (#login_error, .privacy-policy-page-link) or the “Back to site” link. The login_footer action also allows injecting custom HTML at the bottom of the login form for things like support contact information.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only