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');
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.