Thread Starter
Asus24
(@asus24)
I tried modifying the code in this way
wp_enqueue_style( ‘twentytwelve-ie’, get_template_directory_uri() . ‘/css/ie.css’, array( ‘twentytwelve-style’ ), ‘20121010’ );
$wp_styles->add_data( ‘twentytwelve-ie’, ‘conditional’, ‘lt IE 9’ );}
wp_enqueue_style( ‘twentytwelve-ie’, get_template_directory_uri() . ‘/css/ie7.css’, array( ‘twentytwelve-style’ ), ‘20121010’ );
$wp_styles->add_data( ‘twentytwelve-ie’, ‘conditional’, ‘lt IE 8’ );}
but I still did not get the ie7 css, please someone any advice would be appreciated
get_template_directory_uri()
is pointing to parent theme’s folder.
To point to child theme’s, use get_stylesheet_directory_uri()
Also, don’t forget that the lt
in lt IE 9
for example, will load for any IE lower than IE9, so it depends on what you do with those stylesheets.
If you only want specific, dequeue the one from parent and use the conditional without lt
instead, and keep adding one for IE8, and IE7, also without lt
.
As a matter of fact, I don’t think you would need another whole stylesheet for each IE like that. Take a look at what’s inside the <head>
in header.php
.
Theme loads series of IE condition already. You can even make a link to your IE7, IE8 stylesheet in there. Or just make use of .ie7
and .ie8
prefix in html class right in the childtheme stylesheet.
Thread Starter
Asus24
(@asus24)
Thank you paulwpxp so much for responding.
The header.php only has IE condition for language. I tried adding a link to ie 7 css directly to the header and it still did not use it. I would like to try the dequeue option you suggested, can you please give me an example of how the code should look.
/**
* Remove twentytwelve-ie css must use priority greater than 10
* Childtheme's version of ie.css put in childtheme's css folder
*/
function mytheme_dequeue_styles() {
wp_dequeue_style( 'twentytwelve-ie' );
}
add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_styles', 11 );
function mytheme_equeue_styles() {
global $wp_styles;
wp_enqueue_style( 'mytheme-ie', get_stylesheet_directory_uri() . '/css/ie.css', array( 'twentytwelve-style' ), '1.0' );
$wp_styles->add_data( 'mytheme-ie', 'conditional', 'lt IE 9' );
}
add_action( 'wp_enqueue_scripts', 'mytheme_equeue_styles', 11 );
First function is to remove (dequeue) from parent, the second one is to add child theme’s version.
Thread Starter
Asus24
(@asus24)
Thank you so much, it worked so well. I am still struggling trying to write ie 7 compatible css but at least its using the right css files. thanks so much