This is what I use.
/**
* 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 );
Depending on the amount of CSS you needs to override, if it’s not much, you could use .ie
class instead of switching the whole new file.
Thread Starter
Casyi
(@casyi)
Thank you for your reply.
But what do you mean by that exactly? I’m still getting a different stylesheet when adding that to my functions.php or should i change every “mytheme-ie” to my own theme name?
No, it could be used as is.
Just make sure that you have a file named ie.css
inside a folder named css
in your child theme’s folder.
Thread Starter
Casyi
(@casyi)
Ok, thank you. I’m kind of new to wordpress developing and I didn’t make a child theme but I just edited twentytwelve and changed it to a different theme name. I think that’s the reason this function doesn’t work.. Do you have any other ideas?
Thread Starter
Casyi
(@casyi)
When I look into the source of the site in IE8 I get this:
<link id=”twentytwelve-ie-css” href=”http://www.dvadelft.nl/wp-content/themes/aspiringdev/css/ie.css?ver=20121010″ rel=”stylesheet” type=”text/css” media=”all”/>
It shows a version number behind the ie.css. Could that be the problem? It doesn’t seem to get my most recent version of the ie.css. It keeps getting an old one. Everytime I make changes in that ie.css file, it won’t show?
I’m kind of new to wordpress developing and I didn’t make a child theme but I just edited twentytwelve and changed it to a different theme name
That’s my fault, I didn’t read the OP clearly. The code I provided is meant to be used in child theme’s function.
So this is a case of custom theme, it’s different story.
It shows a version number behind the ie.css. Could that be the problem? It doesn’t seem to get my most recent version of the ie.css.
When I directly loaded that css without the ?ver=20121010
, and compared to the one with, files match. So that is not the problem.
Do you have some kind of caching server side ?
Thread Starter
Casyi
(@casyi)
I don’t know. I’ve asked the host but they told me to ask WordPress..
I actually uploaded a modified ie.css with FTP in the right folder. But when I load that css in the browser it’s unchanged. I even added a big HELLO ASDF but it won’t show? Even though I really uploaded it in the same and right path.
Any ideas?