What’s the proper way to add a favicon in WordPress without a plugin? [closed]

What’s the proper way to add a favicon in WordPress without a plugin?

Do I just place a file called favicon.ico with my icon into the root of my site?

Do I also need this code?

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

Some say it’s this code:

<link rel="icon" type="image/png" href="http://yourblog.com/favicon.png" />

And this is for iPhones?

<link rel="apple-touch-icon" href="https://wordpress.stackexchange.com/customIcon.png" />

Any suggestions on software to create it or to convert it from a thumbnail? And what types of files are supported – just .ico?

I saw another thread with so many methods and I was unclear about the best practice for this simple task:
How to change the WordPress favicon?

4

I usually put the icons in an images folder inside my theme so I’d use

function kia_add_favicon(){ ?>
    <!-- Custom Favicons -->
    <link rel="shortcut icon" href="https://wordpress.stackexchange.com/questions/43928/<?php echo get_stylesheet_directory_uri();?>/images/favicon.ico"/>
    <link rel="apple-touch-icon" href="<?php echo get_stylesheet_directory_uri(); ?>/apple-touch-icon.png">
    <?php }
add_action('wp_head','kia_add_favicon');

edited: to add the apple touch icon per the comment, and to clarify that if you are using a child theme, but the favicon is in the parent theme’s image folder, you’d use

get_template_directory_url();

if you are not using a child theme, then either will work

I usually create my favicons here:
http://tools.dynamicdrive.com/favicon/

Leave a Comment