wp_register_style and css conditional wrapper
-
Hi everyone,
I would like to modify and add conditional wrapper on the style.css to get something like that:
<!--[if gt IE 8]> <link rel='stylesheet' id='wfact-style-css' href='my_theme_folder/common/css/style.css?ver=3.6' type='text/css' media='all' /> <![endif]--> <!--[if lte IE 8]> <link rel='stylesheet' id='wfact-ie-only-css' href='my_theme_folder/common/css/mq-fallback.css?ver=3.6' type='text/css' media='all' /> <![endif]-->My problem is that it looks like I can’t override the style.css path as I get:
<!--[if gt IE 8]> <link rel='stylesheet' id='wfact-style-css' href='my_theme_folder/style.css?ver=3.6' type='text/css' media='all' /> <![endif]--> <!--[if lte IE 8]> <link rel='stylesheet' id='wfact-ie-only-css' href='my_theme_folder/common/css/mq-fallback.css?ver=3.6' type='text/css' media='all' /> <![endif]-->The first path is wrong and the second one right.
Here is the code I’ve done:
function wfact_scripts_and_styles() { global $wp_styles; // call global $wp_styles variable to add conditional wrapper around ie stylesheet the WordPress way if (!is_admin()) { // register main stylesheet wp_register_style( 'wfact-style', get_stylesheet_directory_uri() . '/common/css/style.css', array(), '', 'all' ); // ie-only style sheet wp_register_style( 'wfact-ie-only', get_stylesheet_directory_uri() . '/common/css/mq-fallback.css', array(), '' ); // enqueue styles and scripts wp_enqueue_style( 'wfact-style' ); wp_enqueue_style( 'wfact-ie-only' ); $wp_styles->add_data( 'wfact-style', 'conditional', 'gt IE 8' ); // add conditional wrapper around ie stylesheet $wp_styles->add_data( 'wfact-ie-only', 'conditional', 'lte IE 8' ); // add conditional wrapper around ie stylesheet } }Any ideas?
Thanks
The topic ‘wp_register_style and css conditional wrapper’ is closed to new replies.