This method needs you to make sure your source image already has a transparent background, which means it should be a GIF or a PNG. The rest of steps are as above. The one difference in the code is instead of favicon.ico use favicon.png or favicon.gif.
Search for the line of code that begins with <link rel="shortcut icon" and ends with /favicon.ico" />. Overwrite it, if it exists, or add the following code below the <head> HTML tag.
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.png" />
To see your new favicon, clear your browser’s cache. You may need to restart your browser in order to see the new favicon.