favicon size

One item to note is that in the article above, Google now says not to provide a 16×16 pixel favicon.

Once upon a time, a 16×16 pixel favicon was the only size you were supposed to provide. However, now they should be much larger (e.g. 512×512) as Google and others now routinely show favicons next to search results.

Adding favicon.ico to a html page

Browsers will often pick up favicon.ico from the root directory of the site without needing to be told.

You can use this in the head section of a page to specify it if you want:

<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"/>

Adding a favicon.ico to a theme

To add a favicon add this to functions.php in the theme child folder.  (If it doesn’t work ensure the theme isn’t already doing it in the main functions.php file)

//----- Custom favicon -----
function blog_favicon() {
  echo '<link rel="shortcut icon" type="image/x-icon" href="'.get_template_directory_uri().'/favicon.ico" />'."\n";
}
add_action('wp_head', 'blog_favicon');
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.