Replace WordPress Logo on Login Page

01/30/2024
Back to Blogs
<?php
/**
 * Customize WordPress Login Logo.
 *
 * This code replaces the default WordPress logo on the login page with a custom logo.
 * Update the URL to your custom logo and adjust the width and height accordingly.
 *
 * Gist Keywords: wordpress, admin, login
 *
 * @category WordPress
 * @version  1.0.0
 * @author   Knol Aust
 */

add_filter( 'login_head', function () {
	// Update the line below with the URL to your own logo.
	$custom_logo = 'https://example.com/path-to-your-logo.png';
	$logo_width  = 84;
	$logo_height = 84;

	printf(
		'<style>.login h1 a {background-image:url(%1$s) !important; margin:0 auto; width: %2$spx; height: %3$spx; background-size: 100%%;}</style>',
		$custom_logo,
		$logo_width,
		$logo_height
	);
}, 990 );