Code Snippet
Customize Login Page
You know, the one typically at yoursite.com/wp-login.php. These are things you would put in the active theme's functions.php file.
Change the Logo
Is the WordPress logo by default, this changes the file path of that image. Change file path and file name to your own needs.
function custom_login_logo() {
echo '<style type="text/css">h1 a { background: url('.get_bloginfo('template_directory').'/images/logo-login.gif) 50% 50% no-repeat !important; }</style>';
}
add_action('login_head', 'custom_login_logo');Change the URL
... of where clicking that logo goes. By default it goes to WordPress.org, this will change it to your own homepage.
function change_wp_login_url() {
echo bloginfo('url');
}
add_filter('login_headerurl', 'change_wp_login_url');Change the Title
That is, change the title attribute of the image you just replaced. This changes it to the name of your blog in the settings.
function change_wp_login_title() {
echo get_option('blogname');
}
add_filter('login_headertitle', 'change_wp_login_title');
Also helpful is replacing the dashboard logo:
Related question: if using a child theme, how to reference THAT directory? template_directory references the parent theme.
thanks!
ooops, didn’t follow directions:
<style type=”text/css”>
#header-logo { background-image: url(‘.get_bloginfo(‘template_directory’).’/img/dashboardlogo.gif) !important; }
</style>
get_stylesheet_directory_uri();
Hm! Very helpful for me. Thanks, I was looking for this easy way to change the login page in my personal blog.
Umm am a noob at this but do you place it any where like all the way at the bottom of the function.php or dose it have to be in the middle?
Also can i have an example on where to place it. I think that will help alot. Thanks
I believe it does not matter where you put it whether in the middle or at the end of functions.php. Just make sure at the most end of the code in functions.php file, it got no space at all.
For example if the final line is …’change_wp_login_title’); Make sure you press delete button after the “;” until no space left.
Mostly functions.php will not work and giving error functions when this feature is called during page loading. Just my two cents.
If you want to change the CSS of the whole page use:
wordpress has a popular plug-in that works great & simple to use that will do all of the above and more for you
it is wp total hacks
http://wordpress.org/extend/plugins/wp-total-hacks/
This plugin will help me a lot with all my future projects ….
Thanks
I prefer doing the “hacks” myself. I like to be in control.
On change_wp_login_url and change_wp_login_title functions, you should return the data instead of echoing it out. Because echo will output it directly to the browser, while returning the data ensures that other plugins can still hook to your output and modify the result.
When using Filter Hooks you should return the result.
Great tips, really useful. I am using it for my blog. Thanks :)
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.