Created
November 21, 2019 19:29
-
-
Save iamchetanp/d5adfea56506887b2544ff159d540a82 to your computer and use it in GitHub Desktop.
Add Favicon
This file contains hidden or 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
/** | |
* Add Favicon | |
*/ | |
function cpdivi_custom_favicon() { | |
$favicon_path = get_stylesheet_directory_uri() . '/img/favicon/'; | |
ob_start(); | |
?> | |
<link rel="shortcut icon" href="<?php echo esc_attr( $favicon_path ); ?>favicon.ico" /> | |
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-57x57.png" /> | |
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-114x114.png" /> | |
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-72x72.png" /> | |
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-144x144.png" /> | |
<link rel="apple-touch-icon-precomposed" sizes="60x60" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-60x60.png" /> | |
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-120x120.png" /> | |
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-76x76.png" /> | |
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="<?php echo esc_attr( $favicon_path ); ?>apple-touch-icon-152x152.png" /> | |
<link rel="icon" type="image/png" href="<?php echo esc_attr( $favicon_path ); ?>favicon-196x196.png" sizes="196x196" /> | |
<link rel="icon" type="image/png" href="<?php echo esc_attr( $favicon_path ); ?>favicon-96x96.png" sizes="96x96" /> | |
<link rel="icon" type="image/png" href="<?php echo esc_attr( $favicon_path ); ?>favicon-32x32.png" sizes="32x32" /> | |
<link rel="icon" type="image/png" href="<?php echo esc_attr( $favicon_path ); ?>favicon-16x16.png" sizes="16x16" /> | |
<link rel="icon" type="image/png" href="<?php echo esc_attr( $favicon_path ); ?>favicon-128.png" sizes="128x128" /> | |
<meta name="application-name" content="<?php echo esc_attr( bloginfo( 'name' ) ); ?>"/> | |
<meta name="msapplication-TileColor" content="#FFFFFF" /> | |
<meta name="msapplication-TileImage" content="<?php echo esc_attr( $favicon_path ); ?>mstile-144x144.png" /> | |
<meta name="msapplication-square70x70logo" content="<?php echo esc_attr( $favicon_path ); ?>mstile-70x70.png" /> | |
<meta name="msapplication-square150x150logo" content="<?php echo esc_attr( $favicon_path ); ?>mstile-150x150.png" /> | |
<meta name="msapplication-wide310x150logo" content="<?php echo esc_attr( $favicon_path ); ?>mstile-310x150.png" /> | |
<meta name="msapplication-square310x310logo" content="<?php echo esc_attr( $favicon_path ); ?>mstile-310x310.png" /> | |
<?php | |
$favicon = ob_get_contents(); | |
ob_end_clean(); | |
echo $favicon; | |
} | |
add_action( 'wp_head', 'cpdivi_custom_favicon' ); | |
add_action( 'login_head', 'cpdivi_custom_favicon' ); | |
add_action( 'admin_head', 'cpdivi_custom_favicon' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment