I’m updating my self-built theme to HTML5, and easily made a number of changes already.
My theme’s sole stylesheet is added to the page head via wp_enqueue_style
in the functions.php
file, as follows:
function gridded_enqueue_styles() {
wp_enqueue_style('style', get_template_directory_uri() . '/style.css', array(), null, 'all');
}
add_action('wp_enqueue_scripts', 'gridded_enqueue_styles');
The resulting markup is:
<link rel='stylesheet' id='style-css' href='http://grantpalin.com.dev:81/wp-content/themes/gridded/style.css' type='text/css' media='all' />
The stylesheet is loaded, the page renders, all good. However, the HTML5 spec indicates that the type
attribute is no longer needed for the link
, style
, and script
elements.
Looking through the codex reference, I don’t see a way to alter or remove the type
attribute. Can this even be done?
The obvious workaround is to hard-code the stylesheet reference in my header.php
, but that’s avoiding the benefit of the enqueue functionality.
For modify this output you can use that filter:
You can see this hook into
wp-includes/class.wp-styles.php