Here’s another simple little hack for WordPress. This hack allows you to set different favicons for your frontend, backend and login page on your WordPress blog.
This may be useful, if you have many tabs of your blog opened at a time and are having difficulties recognizing admin tabs, or if you just need a different look.
So here’s what you need to add to the functions.php
file of your theme.
function adminfavicon() {
echo '<link rel="icon" type="image/x-icon" href="http://YOUR-URL/favicon.ico" />';
}
add_action( 'admin_head', 'adminfavicon' );
This will set a favicon only for your admin dashboard.
For frontend and login page, create a similar function as above, replacing the favicon.ico
url with another one, and add_action( 'admin_head', 'adminfavicon' );
with any of the following lines:
//Frontend add_action( 'wp_head', 'frontfavicon' ); //Login Page add_action( 'login_head', 'loginfavicon' );
You can also use the same code to set a single favicon for all three places by including them in the same function.
It’s also not necessary to use only .ico, you can use a png or gif image too.
<link rel="icon" type="image/png" href="/favicon.png"> <link rel="icon" type="image/gif" href="/favicon.gif">
To create a favicon, you can use this.
11 thoughts on “Set Different Favicons for Frontend, Backend and Login Page on WordPress”
Thank you for this post. I found it very useful. I followed your instructions and managed to apply a custom favicon to my WordPress login page and admin page.
Thank you very much… It works on the WP site I’m developing in localhost…
function adminfavicon() {
echo ”;
}
//Login Page
add_action( ‘login_head’, ‘loginfavicon’ );
Added the above into my functions.php and did not work…gave me error…looking to change just the login page…is my code right?
thanks
function adminfavicon() {
echo '';
}
//Login Page
add_action( 'login_head', 'loginfavicon' );
No, it’s not. Add this code to your
functions.php
file:Remember to replace favicon URL with yours. Let me know if it works! 🙂
still did not work…I just forgot my url in the code below
Parse error: syntax error, unexpected T_STRING
This is what im getting with your above code using my url
Works now…PERFECT!
Glad you finally got it to work. 🙂
Thanks Renji for providing this useful tip, up to know I only know how to set a favicon for entire site, but this is the first time I came to know this tip of setting different Favs for different sections