Removing default favicon from WordPress

15,709

Solution 1

You can just remove this line in header.php:

<link rel="icon" type="image/png" href="http://www.example.com/favicon.png" />

It isn't loaded automatically, so you can't remove it using a filter/remove_action.

Solution 2

I have used the following filter in the theme functions.php file to remove the original WordPress favicon from being output in the wp_head() function.

add_filter( 'get_site_icon_url', '__return_false' );

This filter removes the URL of the chosen image to be a favicon, so it returns false when WordPress checks for the URL to display it.

There is also an option to create a function that displays the favicon on the following actions:

  • wp_head
  • admin_head
  • wp_head

using the following way:

add_action( 'wp_head', 'prefix_favicon', 100 );
add_action( 'admin_head', 'prefix_favicon', 100 );
add_action( 'wp_head', 'prefix_favicon', 100 );
function prefix_favicon() {
    //code of the favicon logic
    ?>
        <link rel="icon" href="LINK TO FAVICON">
    <?php
}

Solution 3

This question seems quiet old, but new with WordPress 5.4 (03/2020) is a default WP-Favicon, which can be very annoying if you don´t want any. It is also activated for every updated website from version 5.4. Sure, you can change it with the customizer in the normal way, but can´t delete it or need to hack around with transparent images or sth. like that.

Try this little function to remove the favicon (from WP 5.4!) as if it had never been there.

add_action( 'do_faviconico', 'magic_favicon_remover');
function magic_favicon_remover() {
    exit;
}

For more informations, have a look at this:

Solution 4

If a physical /favicon.ico file exists, do nothing and let the server handle the request. for example www.domain.com/favicon.ico

reference

Share:
15,709
user1355300
Author by

user1355300

Updated on June 29, 2022

Comments

  • user1355300
    user1355300 almost 2 years

    How can I remove the default favicon link from the WordPress theme? I know I can replace the favicon but I am looking for using the remove_action or something like that which I can place in my functions.php. Thanks.