How to add a favicon to a WordPress Website

by | Nov 4, 2010 | Web Developer

I’ve recently been asked How to add a favicon to a WordPress Website and the topic continues to pop up. So, I thought I’d post a little about it.

A favicon, also known as a favorites icon, website icon, shortcut icon, url icon, or bookmark icon, is a small, square image, associated with a specific website.

The WordPress.org codex pages already have an article called Creating a Favicon.

In this codex, we are told to add:

[sourcecode language=”html”]<link rel="shortcut icon" href="<?php bloginfo(‘template_directory’); ?>/favicon.ico" />[/sourcecode]

…to the theme’s header.php file, below the <head> HTML tag.

If your favicon needs a transparent background, save it as a .PNG file, using favicon.png instead of favicon.ico, like so:

[sourcecode language=”html”]<link rel="shortcut icon" href="<?php bloginfo(‘template_directory’); ?>/favicon.png" />[/sourcecode]

I usually add about five lines of code these days, to include icons for the various Apple Touch systems.

[sourcecode language=”html”]<link rel="shortcut icon" type="image/x-icon" href="<?php bloginfo(‘template_directory’); ?>/favicon.ico" /><!– favorites icon – favicon.ico –>
<link rel="icon" type="image/x-icon" href="<?php bloginfo(‘template_directory’); ?>/favicon.ico" /><!– desktop icon – favicon.ico –>
<link rel="apple-touch-icon" href="<?php bloginfo(‘template_directory’); ?>/apple-touch-icon-57×57.png" /><!– Other iPhone, iPod Touch, and Android devices –>
<link rel="apple-touch-icon" sizes="72×72" href="<?php bloginfo(‘template_directory’); ?>/apple-touch-icon-72×72.png" /><!– First generation iPad: –>
<link rel="apple-touch-icon" sizes="114×114" href="<?php bloginfo(‘template_directory’); ?>/apple-touch-icon-114×114.png" /><!– iPhone 4 –>[/sourcecode]

…just below the <head> HTML tag.

If your website is powered by WordPress, I suggest doing things the way the WordPress codex recommends it to be done.

sapphire favicon

If writing even a little php code, modifying WordPress template files or following WordPress Codex is outside your comfort level, hire a professional to help.

Logo with image

About the Author:

WebDevRobert

Innovative Technology Professional, working on IT/OT Convergence & Security, in the foundry industry.

Website Designer/Developer since the mid 1990’s.

Apple, Linux and Network Administrator since the late 1990’s.

Background includes several years of IT/OT and IIoT Administration, Communications Infrastructure Design and Project Management.

Currently the VP of Technology for Oil City Iron Works, Inc., in Corsicana, TX.

Subscribe for Updates:

This field is for validation purposes and should be left unchanged.
This field is hidden when viewing the form

Next Steps: Sync an Email Add-On

To get the most out of your form, we suggest that you sync this form with an email add-on. To learn more about your email add-on options, visit the following page (https://www.gravityforms.com/the-8-best-email-plugins-for-wordpress-in-2020/). Important: Delete this tip before you publish the form.
Name(Required)
Email(Required)