Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Last active August 25, 2018 11:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GaryJones/1960257 to your computer and use it in GitHub Desktop.
Save GaryJones/1960257 to your computer and use it in GitHub Desktop.
Enqueue any style sheet with a conditional comment (usually for IE)
<?php
add_action( 'wp_enqueue_scripts', 'prefix_add_ie8_style_sheet', 200 );
/**
* Enqueue an IE-specific style sheet.
*
* Add a style sheet for everyone, then mark it as conditional to IE8 or below.
*
* @author Gary Jones
* @link https://garyjones.io/enqueued-style-sheet-extras#ie
*/
function prefix_add_ie8_style_sheet() {
global $wp_styles;
wp_enqueue_style( 'child-ie8', get_stylesheet_directory_uri() . '/style-ie8.css', [], '1.0.0' );
$wp_styles->add_data( 'child-ie8', 'conditional', 'lte IE 8' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment