• Hi, I know that the no1 reason for this error message:
    “Warning: Cannot modify header information – headers already sent by (output started at (…)/public_html/tricolore/index.php:2) in (…)/public_html/tricolore/wp-rss2.php on line 8”

    is due to the fact of some whitespace being added, I did my homework and searched the matter.

    However, in my situation, This is not the problem. My index.php is:

    “<?php
    echo “<head>”;
    echo “<link rel=\”shortcut icon\” href=\”favicon.ico\” type=\”image/x-icon\”>”;
    echo “<link rel=\”icon\” href=\”favicon.ico\” type=\”image/x-icon\”>”;
    echo “</head>”;
    /* Short and sweet */
    define(‘WP_USE_THEMES’, true);
    require(‘./wp-blog-header.php’);
    ?>”

    As you can see, I’ve added the favico.ico instruction in order to get the little icon to appear in the web Browser. By doing so, I get the error message.

    I don’t see how I could avoid this problem…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    You can’t do that. Don’t add stuff to the main WordPress index.php file. Add it to your theme’s header.php file.

    Or better yet, use a plugin or something similar to add it to the wp_head action hook, like so:
    function add_favicon()
    {
    echo '<link rel="shortcut icon" href="http://example.com/favicon.ico" type="image/x-icon">';
    echo '<link rel="icon" href="http://example.com/favicon.ico" type="image/x-icon">';
    }
    add_action('wp_head','add_favicon');

    You’d put that in either a plugin or the theme’s functions.php file. Also, always use fully-qualified paths to the favicon.ico file, to avoid issues.

    Doesn’t work for the index…

    What do you mean?

    People here can’t read minds.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adding favicon.ico instruction in header causes “Cannot modify header” error’ is closed to new replies.