WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of code that I tend to put into the header.php of every site I do which are specific to Internet Explorer.

I was wondering if there was a way to insert code into a 'standard' header.php.

Yes, I can simply modify the header. But the idea is to make this a plugin which is generic.

Specifically, I'd like to create a plugin to echo the following in the header immediately after the default stylesheet:

<!--[if IE]>
  <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/ie.css" type="text/css" />
share|improve this question
up vote 1 down vote accepted

One way to do it is using the wp_head action:

function wpse85495_header() {
<!--[if IE]>
  <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/ie.css" type="text/css" />

but I think the prefered way is using wp_enqueue_style() in a conditional way as described here:


function wpa85495_enqueue_style(){
    wp_enqueue_style('my-style', WP_PLUGIN_URL . '/my-plugin/style.css', false );
    global $wp_styles;
    $wp_styles->add_data( 'my-style', 'conditional', 'IE' );

add_action( 'wp_enqueue_scripts', 'wpa85495_enqueue_style' );
share|improve this answer
Fabulous! I -knew- there had to be a way that worked within the WP core. Big Cheers! Opens up a number of other possibilities. – jchwebdev Feb 12 '13 at 20:36

You want wp_enqueue_style(). It's considered best practice and all around more elegant than hooking into the wp_head.


share|improve this answer
What would one do about the IE checking using wp_enqueue_style? – brasofilo Feb 12 '13 at 3:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.