How To Add A Favicon To Your WordPress Site

Add Favicon To WordPressAll WordPress blogs should have favicons (the little icon that displays to the left of the website address in your browser screen). The default WordPress favicon just smacks of amateurism. And you’re not an amateur, right?

Fortunately, installing a favicon on your WordPress site is a piece of cake. And although there are plugins available that can do it for you, such a task definitely falls into the “you do absolutely not need to use a plugin to do this” category. After all, you want to keep your site lean and mean.

First of all, you will need a favicon. My site of choice is Favicon Generator and Gallery, where you can convert your own image files into favicons, or just select from their gallery. Once you have your favicon ready, upload it to your WordPress site via the Media Library and copy the image’s URL.

Next, add this simple code to your theme’s functions.php file:

function my_favicon() { ?>
<link rel="shortcut icon" href="yourimagepathgoeshere" >
<?php }
add_action('wp_head', 'my_favicon');

That’s it! The above function will place the link to your favicon in the appropriate place (i.e. between the <head></head> tags).

Creative Commons photo courtesy of ulterior epicure


Comments (17)

  1. If you change your theme will you lose your favicon? if so then its theme dependent. Also, what if a site uses a shared theme and they want a custom favicon?

    • Did you make a backup of your theme’s files? If so, just revert to the backup copy.

      If you didn’t, look in your logs for the specific error. 9 times out of 10 an issue like this is going to be a missing semicolon or PHP that doesn’t include the proper opening or closing tags.

  2. Hi Tom,
    I did everything as you mentioned and know i can’t go to my website and it won’t show my dashboard…when i hit update in the functions.php file of my dashboard,it went to a blank screen like it was refreshing but it now won’t show anything, and when I type my webpage into the address its also a blank white page…oops…i think i broke it…help?