Content filters

tk_icons

This filter can be used to change the icon set output in the head of the theme. The filter is passed an array of associative arrays with each member having three possible keys:

  • filename – the filename of the image (required)
  • sizes – the sizes attribute for the icon (optional)
  • rel – the rel attribute for the icon (optional)

All icons should be stored in the img/icons folder (or a subfolder) in the theme/child theme.

// this will substitute all icons with a single favicon.ico
function my_substitute_site_icons( $icons ) {
    $icons = array(
        array(
            "filename" => "favicon.ico",
            "rel" => "shortcut icon"
        )
    );
    return $icons;
}
add_filter( 'tk_icons', 'my_substitute_site_icons' );

// this will remove icons which have certain values in certain keys
function my_remove_apple_icons( $icons ) {
    return array_filter( $icons, function($icon) {
        return ! ( isset( $icon["rel"] ) && $icon["rel"] === "apple-touch-icon-precomposed" );
    });
}
add_filter( 'tk_icons', 'my_substitute_site_icons' );