Skip to content

Instantly share code, notes, and snippets.

@webdados
Last active December 29, 2021 20:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save webdados/a7702e588070f9a1cfa12dff89b3573c to your computer and use it in GitHub Desktop.
Save webdados/a7702e588070f9a1cfa12dff89b3573c to your computer and use it in GitHub Desktop.
Do not show WordPress 5.4 default WP blue favicon
<?php
//Inspiration: https://gist.github.com/florianbrinkmann/a879099f3d28c5e1d64f2aeea042becf
add_action( 'do_faviconico', function() {
//Check for icon with no default value
if ( $icon = get_site_icon_url( 32 ) ) {
//Show the icon
wp_redirect( $icon );
} else {
//Show nothing
header( 'Content-Type: image/vnd.microsoft.icon' );
}
exit;
} );
@iman-iman
Copy link

Hi! Thanks for making this, it fixed the favicon. However the script itself is showing at the top of the page (in inserted it in the head tags), do you know how to fix that?

@webdados
Copy link
Author

This is not intended to be inserted on the header tags. This is a PHP code snippet to be inserted on your child theme functions.php file or in a PHP code snippets plugin.

@iman-iman
Copy link

iman-iman commented May 13, 2020 via email

@Zodiac1978
Copy link

The changeset https://core.trac.wordpress.org/changeset/13205 shows an additional header line header('Content-Length: 0');

Is this not necessary?

@webdados
Copy link
Author

The changeset https://core.trac.wordpress.org/changeset/13205 shows an additional header line header('Content-Length: 0');
Is this not necessary?

I don't have a clue.

@Zodiac1978
Copy link

Looks like this is not recommended anymore after rfc2616 is followed by rfc7230
https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment