WordPress.org

Ready to get started?Download WordPress

Forums

dkret3
How to use favicons in 4.6? (6 posts)

  1. sheddy
    Member
    Posted 2 years ago #

    Upgraded from 4.5 to 4.6 and my child theme favicon has stopped working and shows the default dkret3 favicon. I see that the code has changed for doing favicon, but due to my ignorance, I can't understand how it is working now.

    I don't see in the example child theme what to change to make it work - I guess I need to put the new favicon code in functions.php into my functions.php and modify it in some way?

    Basically, can anyone give me an idiots' guide to make it work again?! Thanks in advance!

    http://wordpress.org/extend/themes/dkret3/

  2. viktor89
    Member
    Posted 2 years ago #

    probably easier to locate the favicon and replace it with yours.

    it's in dkret3/library/my-dkret3/library/

  3. viktor89
    Member
    Posted 2 years ago #

    and there's one in dkret3/library/images/

    Don't know why, but you can probably tell which one to replace

  4. sheddy
    Member
    Posted 2 years ago #

    Thanks, that'll certainly work until we can figure out the child themes way to do it.

  5. kretzschmar
    Member
    Theme Author

    Posted 2 years ago #

    Dkret simply is a full filtered theme. Therefore you can change everything through the use of own filters inside your child themes functions.php.

    In dkret3 the favicon is added inside functions.php (line 118):

    // add favicon for dkret3
    add_action( 'wp_head', 'dkret_add_favicon' );

    Wp_head is called inside header.php. Therefore the function "dkret_add_favicon" is added to the header of every page.

    You will find the functions of dkret3 inside "dkret3/library/functions". The function "dkret_add_favicon" is saved inside "custom-template-tags.php" (line 29):

    function dkret_add_favicon() {
    $favicon = '<link rel="shortcut icon" href="'.THEME_IMAGES.'/favicon.ico" />';
    
    echo apply_filters( 'dkret_favicon', $favicon );
    }

    Actually this function just adds the html code for the favicon to the head of all pages.

    The best practise is to simply overwrite the 'dkret_favicon' filter.

    Inside your child themes function.php add these small code:

    function my_child_favicon() {
    	echo '<link rel="shortcut icon" href="'.CHILD_THEME_URI.'/library/images/favicon.ico" />';
    }
    add_filter( 'dkret_favicon', 'my_child_favicon' );

    This will actually overwrite the standard markup. Please change the URL if the favicon is not saved inside "my-dkret3/libray/images".

  6. sheddy
    Member
    Posted 2 years ago #

    Many thanks for the help and explanation, (and thanks for making the theme and keeping it up-to-date)

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags