• Running wp 3.2.1 on local pc under XAMPP
    Created website named “testsite.com”
    Added”twentyeleven-child” folder
    Created ico image and placed it in root directory of testsite.com
    Created and placed “style.css” and “favicon_function.php” files in child folder

    Code in css file is:

    Theme Name:     Twenty Eleven Child
    Theme URI:      http: //testsite.com/
    Description:    Child theme for the Twenty Eleven theme
    Author:         xxx xxxxx
    Author URI:     http: //testsite.com/
    Template:       twentyeleven
    Version:        0.1.0
    
    @import url("../twentyeleven/style.css");
    
    require_once( get_stylesheet_directory(). '/favicon_function.php' );

    Code in php file is:

    <?php 
    
    function favicon_link() {
        echo '<link rel="shortcut icon" type="image/x-icon" href="/testsite_icon.ico" />' . "\n";
    }
    add_action('wp_head', 'favicon_link');
    
    ?>

    No favicon appears AND everything on twentyeleven index page is left justified. Can anyone help?

Viewing 1 replies (of 1 total)
  • I know this is six months too late, but I just went through the same tutorial and found the problem. So, for any future people with the same issue, here is the answer:

    Add “get_stylesheet_directory_uri()” to your link so it is pulling the favicon.ico from your child theme directory. You want it there and not in your parent theme folder. It’s best to keep everything separated.

    So, the code that worked for me is:

    function favicon_link() {
        echo '<link rel="shortcut icon" type="image/x-icon" href="'.get_stylesheet_directory_uri().'/favicon.ico" />' . "\n";
    }
    add_action('wp_head', 'favicon_link');

Viewing 1 replies (of 1 total)
  • The topic ‘child theme and favicon coding problem’ is closed to new replies.