Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Enqueue and Register Internet Explorer CSS Style Sheets in WordPress

February 2, 2014 3 Comments

ie-register-enqueue
To  enqueue and register IE stylesheets in WordPress as appose to manually hardcoding them into a header.php file you need to add a function with the style sheet registered and enqueued and then add an action to load the stylesheet, the function also needs to contain the conditions of which IE version is targeted.

Add in a function and action

Open up functions.php and add in a function and action like so:

function ie_style_sheets () {
//code goes here
}

add_action ('wp_enqueue_scripts','ie_style_sheets');

The function in this example is named ie_style_sheets(), you can name it what you like, the action wp_enqueue_scripts is going to load the function ie_style_sheets with all styles and scripts inside it.

 

Register and Enqueue the style sheet

function ie_style_sheets () {
wp_register_style( 'ie8', get_stylesheet_directory_uri() . '/ie8.css'  );

wp_enqueue_style( 'ie8' );
}

add_action ('wp_enqueue_scripts','ie_style_sheets');

The above for instance will target just IE8, register the style sheet and enqueue it.

 

Add in the IE Conditions

function ie_style_sheets () {
wp_register_style( 'ie8', get_stylesheet_directory_uri() . '/ie8.css'  );
$GLOBALS['wp_styles']->add_data( 'ie8', 'conditional', 'lte IE 8' );

wp_enqueue_style( 'ie8' );
}

add_action ('wp_enqueue_scripts','ie_style_sheets');

The above for instance will target just IE8 and lower .

 

Add in Multiple Variations if Required

function ie_style_sheets () {
wp_register_style( 'ie8', get_stylesheet_directory_uri() . '/ie8.css'  );
$GLOBALS['wp_styles']->add_data( 'ie8', 'conditional', 'lte IE 9' );

wp_register_style( 'ie6', get_stylesheet_directory_uri() . '/ie6.css'  );
$GLOBALS['wp_styles']->add_data( 'ie6', 'conditional', 'lt IE 7' );

wp_enqueue_style( 'ie8' );
wp_enqueue_style( 'ie6' );
}

add_action ('wp_enqueue_scripts','ie_style_sheets');

One of the key benefits of setting it up like this is that you can bundle in all your styles and scripts into one function.

Cats: CSS, WordPress Tags: ie

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Discuss

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls
Get DesktopServer

Lynda

Lynda.com Online Training Videos

TreeHouse

smlinks

Learn WordPress
osx-modify-shell-path

How to Add to the Shell Path in macOS Big Sur and Catalina using Terminal

October 19, 2019

virtual-hosts osx 10.10 yosemite

Set up Virtual Hosts on macOS Catalina 10.15 in Apache

October 19, 2019

Installing Homebrew on macOS Catalina 10.15, Package Manager for Linux Apps

October 18, 2019

Where is the bash shell in macos Catalina?

October 12, 2019

Refine your search

  • All
  • Modules
  • Themes
  • Documentation
  • Forums & Issues
  • Groups

RSS ars technica

  • What to expect from Apple’s Worldwide Developers Conference next week
  • Breaking down why Apple TVs are privacy advocates’ go-to streaming device
  • Musi says evidence shows Apple conspired with music industry on App Store ban
  • Trump threatens Apple with 25% tariff to force iPhone manufacturing into US
  • I helped a lost dog’s AirTag ping its owner: An ode to replaceable batteries

RSS mac surfer

  • Tot is new text editor for Mac, iPhone, and iPad focused on constraints and ease of use
  • TiPbITS: Google Drive Sorting Can Hide New Documents
  • How to take a screenshot on a MacBook Pro
  • How To Create Simple Animation With Mac Keynote
  • Last Week on My Mac: Virus pandemics

Donate

Copyright © 2025· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2025 · gee on Genesis Framework · WordPress · Log in