How to Create an Empty Favicon in WordPress

Create an Empty Favicon in WordPress

Your site doesn’t have a favicon and online speed testing tools give you a 404 error regarding this file? Let’s look at a simple solution to the problem – creating an empty favicon.

Services like Pingdom and WebPageTest throw an error if they can’t find the site.ru/favicon.ico. There is no consensus on how the absence of this file will be displayed on the site. But if you care about the success of your resource, then the mistake needs to be corrected.

You can simply upload the favicon to the site root via FTP. But if there is no access to the site files or the favicon is not provided at all, then use one of the following simple methods.

How to Create an Empty Favicon in WordPress

The idea is simple – to create a file without an image using a special code.

Method 1: Code in the Theme Template

It is highly recommended to use a child theme so you don’t lose your edits.

Open the active WordPress theme file and insert the header of the line.php before the closing tag:</head>

Also see: How to allow public viewing of unpublished WordPress posts

<Link href = "data: image / x-icon; base64, iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T /////// 8JWPfcAAAACXBIWXMAAABIAAAASABGyWs + AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII =" rel = "icon" type = "image / x-icon" />

Method 2. Header Hook

This method is more general. It does not provide for edits in theme templates. Uses a WordPress hook that adds the necessary data to the site header.

The following code can be added to the Code Snippets plugin. It works independently of the theme or other extensions.

function wpschool_add_favicon() {
echo '<link href = "data: image / x-icon; base64, iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T /////// 8JWPfcAAAACXBIWXMAAABIAAAASABGyWs + AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII =" rel = "icon" type = "image / x-icon" />';
}
add_action( 'wp_head', 'wpschool_add_favicon' );

Leave a comment

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