Skip to content

Instantly share code, notes, and snippets.

@robertdevore
Last active September 18, 2015 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertdevore/dde2a8bc05e4c0fb7572 to your computer and use it in GitHub Desktop.
Save robertdevore/dde2a8bc05e4c0fb7572 to your computer and use it in GitHub Desktop.
Let your theme's customizer logo upload option override the default WordPress login logo
<?php
/*
* Change the "mnml" text througout the code below to whatever you'd like to use
*
* Also, make sure the get_theme_mod instances are changed to your customizer option names
*
*/
// Add custom logo to login page if it's uploaded through the customizer
if ( get_theme_mod( 'mnml_logo' ) ) {
function mnml_login_logo() {
list($width,$height) = getimagesize(get_theme_mod( "mnml_logo" ));
echo '<style type="text/css">
#login {
width: '. $width .'px !important;
}
h1 a {
background-image:url('. get_theme_mod( "mnml_logo" ) .') !important;
background-size: '. $width .'px !important;
width: '. $width .'px !important;
height: '. $height .'px !important;
}
</style>';
}
add_action('login_head', 'mnml_login_logo');
// Change login page logo link to the website home page
function mnml_login_logo_url() {
return get_bloginfo( 'url' );
}
add_filter( 'login_headerurl', 'mnml_login_logo_url' );
// Change login page logo title to the website name
function mnml_login_logo_url_title() {
return get_bloginfo( 'name' );
}
add_filter( 'login_headertitle', 'mnml_login_logo_url_title' );
} // if get_theme_mod('mnml_logo')
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment