Skip to content

Instantly share code, notes, and snippets.

@chillybin
Last active August 29, 2015 14:26
Show Gist options
  • Save chillybin/70ddc29e05d8b330b2de to your computer and use it in GitHub Desktop.
Save chillybin/70ddc29e05d8b330b2de to your computer and use it in GitHub Desktop.
Adding custom Favicon
<?php // Don't include this when copying code
add_filter( 'genesis_pre_load_favicon', 'cb_pre_load_favicon' );
/**
* Simple favicon override to specify your favicon's location.
*
* @since 2.0.0
*/
function cb_pre_load_favicon() {
return get_stylesheet_directory_uri() . '/images/favicon/favicon.ico';
}
remove_action( 'wp_head', 'genesis_load_favicon' );
add_action( 'wp_head', 'cb_load_favicons' );
/**
* Show the best favicon, within reason.
*
* See: http://www.jonathantneal.com/blog/understand-the-favicon/
*
* @since 2.0.4
*/
function cb_load_favicons() {
$favicon_path = get_stylesheet_directory_uri() . '/images/favicon';
?>
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo $favicon_path; ?>/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="<?php echo $favicon_path; ?>/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo $favicon_path; ?>/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="<?php echo $favicon_path; ?>/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo $favicon_path; ?>/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="<?php echo $favicon_path; ?>/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo $favicon_path; ?>/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="<?php echo $favicon_path; ?>/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo $favicon_path; ?>/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="<?php echo $favicon_path; ?>/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="<?php echo $favicon_path; ?>/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="<?php echo $favicon_path; ?>/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="<?php echo $favicon_path; ?>/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="<?php echo $favicon_path; ?>/manifest.json">
<link rel="shortcut icon" href="<?php echo $favicon_path; ?>/favicon.ico">
<meta name="msapplication-TileColor" content="#52d2e0">
<meta name="msapplication-TileImage" content="<?php echo $favicon_path; ?>/mstile-144x144.png">
<meta name="msapplication-config" content="<?php echo $favicon_path; ?>/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<? }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment