How To Force a Favicon Refresh in Website

Favicon is a small icon typically displayed in the top address bar of a browser next to the site name. Just like logo, favicon represents the identity or branding of the website. Sometimes favicon also known as shortcut icon, website icon, or URL icon. The favicon dimension should be a set of 16×16, 32×32 and 48×48 picture.

You can generate favicon for Web, Android, Microsoft, and iOS (iPhone and iPad) Apps from here.

Force a Favicon Refresh

How To Force a Favicon Refresh in Website

Sometimes while browsing the site, you’ll see the favicon not appearing on the website. Or other times, the old icons are being displayed on some browsers. There are even some cases where favicons only load in front pages and disappears while browsing other pages.

To display favicon permanently on the website without any hassle, we need to force a favicon refresh in a website. And to refresh your site’s favicon, you should force browsers to download the newer version using the link tag & a query string on your file.

While there are literally tons of solutions for this specific problem, I always use simple but effective one line code to eliminate this error. And it has worked everytime.

The Solution

Just add the below line of code in your header.php file.

  <link rel="icon" href="http://www.yoursite.com/favicon.ico?v=2" />

As I said earlier, there are many solutions for this, don’t complicate things even more. Use the above code as your first priority and if it didn’t work, use this one:

<link rel="icon" type="image/x-icon" href="http://www.yoursite.com/favicon.ico?v=2" />

It should work!!

ALSO READ  How to Add Categories to Pages in WordPress

Source: StackOverflow