Tutorial: How to serve a default theme to old versions of IE

This could probably be more efficient but it's so small it doesn't matter.

Most modern (CSS3+) themes barf all over old versions of IE. If your theme doesn't have issues then it's probably so bloated with other code that you've traded one evil for another, or you're missing out on a lot of cool stuff as a result.

The solution, naturally, is to intercept IE6, 7, and 8 then force those browsers to use TwentyTwelve. Bear in mind that you should switch to Twenty Twelve and fully configure the theme first or it'll look brutally bad.

Save this code to 'serve2012.php', upload it to your plugins directory, and activate.

Plugin Name: Alternate IE
Plugin URI: http://imperativeideas.com
Description: This plugin will serve the twentytwelve, or whatever theme you (manually) configure to any visitors using IE6, IE7, or IE8.
Author: Imperative Ideas
Author URI: http://www.imperativeideas.com
Version: 1.0

add_filter('template', 'serve_default_to_ieold');
add_filter('option_template', 'serve_default_to_ieold');
add_filter('option_stylesheet', 'serve_default_to_ieold');
function serve_default_to_ieold($theme) {
    if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8') !== false) {
        $theme = 'twentytwelve';
    } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false) {
        $theme = 'twentytwelve';
    } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
        $theme = 'twentytwelve';

    return $theme;

You can get extra tricky and specify a different theme for each browser if you like.

Enjoy ~

Ian / Imperative Ideas