how to add favicon to wordpress theme

how to add favicon to wordpress theme

Favion is small image icon which is shown on browser left top side. Left side of browser address bar, we can see the favicon image. Here in this article We will show you, how to add add favicon to wordpress theme.

how to add favicon to wordpress theme

Create favicon image using photoshop or any photo editing tool. Favicon image side should be 16x16px or 32x32px. Many times favicon image should be .ico or png format. All latest browser are able to show png format image but in old browser icon format image should be supported.

Just copy paste the following lines to your function.php file.

<?php 
function add_favicon() {
?>
<link rel="shortcut icon" href="<?php echo bloginfo('stylesheet_directory') ?>/images/favicon.ico" >
<?php 
}
add_action('wp_head', 'add_favicon');
?>

if wp_head() function added in your header.php file, If that function not added then this hack will never work

Or you can just add favicon image file in themes folder and use following code in header.php file.


<link rel="icon" href="https://purabtech.in/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="https://purabtech.in/favicon.ico" type="image/x-icon" />

how to add favicon to wordpress theme
how to add favicon to wordpress theme

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.