Skip to content

Instantly share code, notes, and snippets.

@terrytsang
Created September 11, 2022 09:12
Show Gist options
  • Save terrytsang/6eab545dde3d412e582db7bc4083bf4c to your computer and use it in GitHub Desktop.
Save terrytsang/6eab545dde3d412e582db7bc4083bf4c to your computer and use it in GitHub Desktop.
<?php
//add this code into your theme functions.php file
//step 1: change the admin login logo to the uploaded media image file
if ( !function_exists('tt_wp_admin_login_logo') ) :
function tt_wp_admin_login_logo() { ?>
<style type="text/css">
body.login div#login h1 a {
background-image: url('https://www.yoursite.com/wp-content/uploads/2022/09/your-logo.jpg');
}
</style>
<?php }
add_action( 'login_enqueue_scripts', 'tt_wp_admin_login_logo' );
endif;
//step 2: change the admin login URL to website home URL
if ( !function_exists('tt_wp_admin_login_logo_url') ) :
function tt_wp_admin_login_logo_url() {
return home_url();
}
add_filter( 'login_headerurl', 'tt_wp_admin_login_logo_url' );
endif;
//step 3: change the admin login logo title to the blog title
if ( !function_exists('tt_wp_admin_login_logo_title') ) :
function tt_wp_admin_login_logo_title( $headertext ) {
$headertext = esc_html__( get_bloginfo('name'), 'plugin-textdomain' );
return $headertext;
}
add_filter( 'login_headertext', 'tt_wp_admin_login_logo_title' );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment