Use Your Logo on the Login Page
Replaces the WordPress logo on the login screen with your theme logo, your Site Icon, or an image URL you provide.
Opens WPIDE on
Code
add_action( 'login_enqueue_scripts', function () {
$logo_url = ''; // Optional: paste a full image URL here.
if ( '' === $logo_url ) {
$logo_id = (int) get_theme_mod( 'custom_logo' );
$logo_url = $logo_id ? (string) wp_get_attachment_image_url( $logo_id, 'medium' ) : '';
}
if ( '' === $logo_url && has_site_icon() ) {
$logo_url = get_site_icon_url( 192 );
}
if ( '' === $logo_url ) {
return;
}
printf(
'<style>.login h1 a{background-image:url("%s");background-size:contain;background-position:center;width:100%%;max-width:240px;height:100px;}</style>',
esc_url( $logo_url )
);
} );
Notes
Order of preference: the URL in $logo_url, the Customizer logo, then the Site Icon.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.