Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For those who are curious, I'm changing the theme but this theme relies on CSS3 and HTML5 and displays very ugly in IE 8 or below. - Especially the navigation.

What I want to do is keep my old theme and use it for IE users only, I assume if this can be done for a mobile site, it can for IE. Would it be easier to just get another WP installation and duplicate the content (What's the easiest way to do this?). Or is there a method, such as the mobile method to redirect users to that theme.

My plan was, create a second installation with the existing theme then somehow grab the content from the main site and add and IF code redirecting IE users. Is this possible, or is there an easier/ or simpler way?

share|improve this question
    
or you could always use some java and when a users is on a non supported broswer notify them that they should update there browser. Also i believe that the current version or maybe its the next 3.2 version has a built in function for this. Broswe Happy –  xLRDxREVENGEx May 20 '11 at 18:32
    
some javaSCRIPT, java won't do much good here. sorry, pet peeve. –  Milo May 21 '11 at 18:37
add comment

1 Answer 1

up vote 2 down vote accepted

maybe you can somehow use template redirect? I'm not too clear on how it works, but it may be worth investigating.

function my_check_is_ie() {
    global $is_winIE;
    if ( ! $is_winIE ) return;

    // load template for IE
    include(TEMPLATEPATH . '/IE_template.php');

    // or maybe?
    if( is_home() ) include(TEMPLATEPATH . '/IE_home.php');
    elseif( is_single() ) include(TEMPLATEPATH . '/IE_single.php');
    // etc.
}

add_action('template_redirect', 'my_check_is_ie');

Edit- ok, I think I've figured it out. I haven't tested this in the wild, so make sure it works first! You'll have to make this a plugin, since once the theme is loaded it's too late to pull the theme switch...

<?php
/*
Plugin Name: randomkljsaduiyerth
*/
global $is_winIE;
if($is_winIE){
    add_filter('template', 'my_switch_themes');
    add_filter('stylesheet', 'my_switch_themes');
}
function my_switch_themes(){
    // return the name of your IE theme
    return 'my-IE-theme-Name-Here'; 
}

Edit2-

you could add another check for the presence of a GET variable if you wanted to let people switch via a link like: http://yourdomain.com/?IE_version

if( isset($_GET['IE_version']) ):
    // add_filter here, or better yet if you're doing a number of checks,
    // set a flag if any check is true and add_filter last
endif;

you could also use cookies to store the theme preference

// check the cookie
if( isset($_COOKIE["my_domain_cookie"]) )

// set the cookie
setcookie("my_domain_cookie", "My Cookie Val", time()+60*60*24*30);
share|improve this answer
1  
I'd do if ( ! $is_winIE ) return;. Anyway: Did someone ever check if this works on Mac OS or Linux too? +1. –  kaiser May 20 '11 at 18:36
1  
@kaiser thanks, good idea, I'll update the answer. the browser check part works in mac and linux, uses $_SERVER['HTTP_USER_AGENT'] in the code. you can block or spoof it of course. –  Milo May 20 '11 at 18:48
    
also - you might lose user agent or have it changed if you go through a proxy. it's not bulletproof. –  Milo May 20 '11 at 18:56
    
@Milo Okay, I tried this (with @kaiser's edited code), it does work but how do I chose what theme I wish to redirect too? –  itsdaniel0 May 20 '11 at 18:57
    
@itsdaniel0 I've edited the code. it's a bit manual I think, the templates all sit in the same directory but you manually load the IE versions. –  Milo May 20 '11 at 18:58
show 7 more comments

Your Answer

 
discard

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.