Falcon1986-Online

Home of a med student who likes to manage websites and talk tech!

Specify favicon for use within WordPress Dashboard

with one comment

WordPress LogoOne of my little peeves about WordPress is that a blog’s favicon disappears once you enter the WordPress Dashboard. A browser’s default behaviour upon landing on a website is to load favicon.ico from the root web directory for that website (i.e. http://www.mydomain.tld/favicon.ico), but if it is not there nothing is loaded. While dropping a favicon within the root web directory should be all that is required, sometimes specifying its location within your theme’s header.php is required to point browser’s in the right direction, but how can you do the same for the Dashboard? In this post, I will show you how you can make your favicon persistent in this location using functions.php.

Continuing with the recent posts on adding functionality to WordPress via functions.php, navigate to your theme’s files and, with a simple text editor, open the functions.php file. If one does not exist, create one and save it to your theme’s directory. Add the following lines of code and modify the domain reference to suit your setup and the location of your favicon. Save and re-enter your Dashboard to see the effects.

// Specify favicon for Dashboard
function favicon4admin() {
 echo '<link rel="Shortcut Icon" type="image/x-icon" href="http://www.mydomain.tld/favicon.ico" />';
}
add_action( 'admin_head', 'favicon4admin' );

As usual, this is a per-theme modification, so you will need to reapply if you automatically update your theme or switch to another theme.

About these ads

Written by falcon1986

9 March, 2011 at 11:02 AM

Posted in Wordpress

Tagged with

One Response

Subscribe to comments with RSS.

  1. Nice.. I wanted this functionality, I searched, I found, I installed, it works, I tweeted.. Woohoo.. Thanks.. :)

    Sunny

    21 June, 2011 at 7:21 PM


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: