There may be situations where you want to display a different favicon on each wordpress page, for example, you host different pages with one wordpress Installation, or you just want to have a different favicon for other reasons.

This snippet comes in handy if you want to achieve that.

You’re more than welcome to just contact us directly to implement this cool feature!

Things you will need to use this on your website:

  • Favicon
  • WordPress Child Theme

First, upload your favicon to the media gallery.

Once this is done, you will need to find the id of the page where you want to put a different favicon.

Finding your WordPress page ID its a simple task. To find it, open your WordPress dashboard and click on Pages > All Pages.

Then, select the page that you need to find the ID for, and open it in edit mode

Once the page has opened, you need to look at the URL in your web browser’s address bar.

After this is done, just drop the code below in your child theme’s functions.php and replace content with your own information

add_filter( ‘get_site_icon_url’,‘atw_filter_favicon’, 10, 3 );
function atw_filter_favicon ($url, $size, $blog_id) {
  global $post;
  if ( is_page( 'replace_this_with_page_id ) ) $url = ‘replace_this_with_favicon_path’;
  return $url;
  }

Contact us to learn about adopting the web for your business

    Author Guido Magaldi

    Guido is a professional front end developer. He loves creating and developing dream websites for our clients. When he is not at the computer working on awesome website design, he is kitesurfing the glacial waters of Bariloche .

    More posts by Guido Magaldi