Last active
June 4, 2021 19:22
-
-
Save tigredanky/917fde0c340295b39c072c08d72a468f to your computer and use it in GitHub Desktop.
WordPress Functions.php | Favicon Frontend & Admin Option
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 | |
// FAVICON ADDITION | |
function add_my_favicon() { | |
if ( ! is_admin() ) { | |
//$favicon_path = get_site_url() . '/img/favicon-client.png'; | |
$favicon_path = get_site_url() . '/i/favicon-client'; | |
} else { | |
//$favicon_path = get_site_url() . '/img/favicon-admin.png'; | |
$favicon_path = get_site_url() . '/i/favicon-admin'; | |
} | |
echo | |
'<!-- generics --> | |
<link rel="icon" href="' . esc_url($favicon_path) . '-32.png" sizes="32x32"> | |
<link rel="icon" href="' . esc_url($favicon_path) . '-57.png" sizes="57x57"> | |
<link rel="icon" href="' . esc_url($favicon_path) . '-76.png" sizes="76x76"> | |
<link rel="icon" href="' . esc_url($favicon_path) . '-96.png" sizes="96x96"> | |
<link rel="icon" href="' . esc_url($favicon_path) . '-128.png" sizes="128x128"> | |
<link rel="icon" href="' . esc_url($favicon_path) . '-192.png" sizes="192x192"> | |
<link rel="icon" href="' . esc_url($favicon_path) . '-228.png" sizes="228x228"> | |
<!-- Android --> | |
<link rel="shortcut icon" sizes="196x196" href="' . esc_url($favicon_path) . '-196.png" /> | |
<!-- iOS --> | |
<link rel="apple-touch-icon" href="' . esc_url($favicon_path) . '-120.png" sizes="120x120"> | |
<link rel="apple-touch-icon" href="' . esc_url($favicon_path) . '-152.png" sizes="152x152"> | |
<link rel="apple-touch-icon" href="' . esc_url($favicon_path) . '-180.png" sizes="180x180">'; | |
} | |
add_action( 'wp_head', 'add_my_favicon' ); //front end | |
add_action( 'admin_head', 'add_my_favicon' ); //admin end | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment