Created
May 26, 2014 19:30
-
-
Save jrfnl/4a6c3ab31233963caf4b to your computer and use it in GitHub Desktop.
Easily add favicon and apple touch and Windows8 icons to the html page header of a WordPress website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add favicon and apple touch and Windows8 icons to the html page header of a WordPress website | |
* | |
* Add the favicon link properly to the page header so it will work in all browsers | |
* Add apple touch icons | |
* Add the Windows8 icons | |
* Presumes you will add the icons in the theme directory in a subfolder '/images/icons/' | |
* - adjust if you use another folder. | |
* You may also want adjust to the background-color of the Windows8 tiles and can do so | |
* in the second line of the Windows8 block. | |
* | |
* You can use any of or a combination of the below sites to generate the actual image files: | |
* http://www.buildmypinnedsite.com/en | |
* http://iconifier.net/ | |
* http://realfavicongenerator.net/ | |
* | |
* Generates echo-ed html, no return | |
*/ | |
function add_icon_links() { | |
/* Normal favicons */ | |
echo ' | |
<link rel="shortcut icon" type="image/x-icon" href="' . get_stylesheet_directory_uri() . '/favicon.ico" /> | |
<link rel="bookmark icon" type="image/x-icon" href="' . get_stylesheet_directory_uri() . '/favicon.ico" /> | |
<link rel="icon" type="image/ico" href="' . get_stylesheet_directory_uri() . '/favicon.ico" />'; | |
/* Apple Touch icons */ | |
/* For third-generation iPad with high-resolution Retina display: */ | |
echo ' | |
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="' . get_stylesheet_directory_uri() . '/images/icons/apple-touch-icon-144x144-precomposed.png"> | |
' /* For iPhone with high-resolution Retina display running iOS >= 7: -->*/ . | |
'<link rel="apple-touch-icon-precomposed" sizes="120x120" href="' . get_stylesheet_directory_uri() . '/images/icons/apple-touch-icon-120x120-precomposed.png"> | |
' /* For iPhone with high-resolution Retina display running iOS <= 6: */ . | |
'<link rel="apple-touch-icon-precomposed" sizes="114x114" href="' . get_stylesheet_directory_uri() . '/images/icons/apple-touch-icon-114x114-precomposed.png"> | |
' /* For first- and second-generation iPad: */ . | |
'<link rel="apple-touch-icon-precomposed" sizes="72x72" href="' . get_stylesheet_directory_uri() . '/images/icons/apple-touch-icon-72x72-precomposed.png"> | |
' /* For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: */ . | |
'<link rel="apple-touch-icon" href="' . get_stylesheet_directory_uri() . '/images/icons/apple-touch-icon.png" /> | |
<link rel="apple-touch-icon-precomposed" href="' . get_stylesheet_directory_uri() . '/images/icons/apple-touch-icon-57x57-precomposed.png"> | |
<meta name="apple-mobile-web-app-title" content="' . get_bloginfo( 'name' ) . '">'; | |
/* Windows 8 icon and RSS feed*/ | |
echo ' | |
<meta name="application-name" content="' . get_bloginfo( 'name' ) . '"> | |
<meta name="msapplication-TileColor" content="#F9F9F9"> | |
<meta name="msapplication-TileImage" content="' . get_stylesheet_directory_uri() . '/images/icons/windows8-144x144.png"/> | |
<meta name="msapplication-square70x70logo" content="' . get_stylesheet_directory_uri() . '/images/icons/tiny.png"/> | |
<meta name="msapplication-square150x150logo" content="' . get_stylesheet_directory_uri() . '/images/icons/square.png"/> | |
<meta name="msapplication-wide310x150logo" content="' . get_stylesheet_directory_uri() . '/images/icons/wide.png"/> | |
<meta name="msapplication-square310x310logo" content="' . get_stylesheet_directory_uri() . '/images/icons/large.png"/> | |
<meta name="msapplication-notification" content="frequency=30;polling-uri=' . get_bloginfo( 'rss2_url' ) . '&id=1; cycle=1"/> | |
'; | |
} | |
add_action('wp_head', 'add_icon_links'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment