Add a custom favicon to your WordPress site

First, create a 16×16 png/ico/gif favicon and drop it in you theme’s root folder. That’s the one we will show in this example!

Add this to your theme’s functions.php.

/*  Custom favicon
/* ------------------------------------ */
function alx_favicon() {
	echo '<link rel="shortcut icon" href="'.get_template_directory_uri().'/favicon.png" />'."\n";
}
add_filter( 'wp_head', 'alx_favicon' );

It’s that simple.

Useful tip: To force-refresh a favicon that you’ve updated, just add ?v=2 to the image url, like /favicon.png?v=2.

Leave a Reply

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