Add attribute to link tag that’s generated through wp_register_style?

Looking at the WP_Style class, we find the style_loader_tag filter, that might be useful.

Try for example:

add_filter( 'style_loader_tag', function( $link, $handle )
{
    if( 'google-fonts' === $handle )
    {
        $link = str_replace( '/>', ' data-noprefix />', $link );
    }
    return $link;
}, 10, 2 );

Leave a Comment