Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[WordPress] Mini plugin, adds favicons, touch icons and tiles for desktop browsers, iOS, Android and Windows. Generated HTML output via Requires a sub-directory /img to store all images in. HEADS UP: This is no longer needed as of WordPress 4.3!
* Plugin Name: Real Favicons
* Description: Adds favicons, touch icons and tiles for desktop browsers, iOS, Android and Windows. Generate HTML output via <a href=""></a>. Store all generated images in sub-directory /img.
* Version: 2014.01
* Author: Caspar Hübinger
* Author URI:
* License: GNU General Public License v2 or later
* License URI:
if ( ! defined( 'ABSPATH' ) )
* Load plugin.
function real_favicons() {
add_action( 'wp_head', 'real_favicons_add_favicons' );
add_action( 'plugins_loaded', 'real_favicons' );
* Add the favicon.
* @return string
function real_favicons_add_favicons() {
$img_url = plugin_dir_url( __FILE__ ) . "img";
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo $img_url; ?>/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo $img_url; ?>/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo $img_url; ?>/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo $img_url; ?>/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="<?php echo $img_url; ?>/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="<?php echo $img_url; ?>/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="<?php echo $img_url; ?>/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="152x152" href="<?php echo $img_url; ?>/apple-touch-icon-152x152.png">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-196x196.png" sizes="196x196">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-160x160.png" sizes="160x160">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="<?php echo $img_url; ?>/favicon-32x32.png" sizes="32x32">
<meta name="msapplication-TileColor" content="#0095bc">
<meta name="msapplication-TileImage" content="<?php echo $img_url; ?>/mstile-144x144.png">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment