Change WordPress login logo with code

Author: Aleš Sýkora, 6. 11. 2020

Need to change wordpress login logo? Use this code in custom plugin or in Code Snippets plugin. Change the background image url to your image and Link Title to your site name for example.

//Custom logo change

function login_logo() { ?>
    <style type="text/css">
        #login h1 a, .login h1 a {
            background-image: url(;
<?php }
add_action( 'login_enqueue_scripts', 'login_logo' );

//Custom logo URL

function login_logo_url() {
    return home_url();
add_filter( 'login_headerurl', 'login_logo_url' );
function login_logo_url_title() {
    return 'Link title';
add_filter( 'login_headertitle', 'login_logo_url_title' );