How to add a favicon to WordPress the correct way

Last updated on

Open functions.php in your WordPress themes folder (usually located in /wp-content/themes/{theme_name}/) and paste the following code to the bottom of the file.

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

You can generate .ico files and more by searching “favicon generator” on Google.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

Leave a reply

Your email address will not be published. Required fields are marked *