Dynamically change url or WordPress theme if UserAgent is iPhone Dynamically change url or WordPress theme if UserAgent is iPhone wordpress wordpress

Dynamically change url or WordPress theme if UserAgent is iPhone


http://www.nathanrice.net/blog/serve-ie6-visitors-the-default-wordpress-theme/ demonstrates how to use template filter to dynamically change the WordPress theme (in this case IE6, but it could be for a mobile user agent):

add_filter('template', 'serve_default_to_iesix');add_filter('option_template', 'serve_default_to_iesix');add_filter('option_stylesheet', 'serve_default_to_iesix');function serve_default_to_iesix($theme) {    if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false)        $theme = 'default';    return $theme;}


Have you looked at iWPhone?

It's a Wordpress plugin and theme that automatically takes care of detecting whether the visitor is from an iPhone and formats things appropriately. Pretty easy to substitute your own custom iPhone CSS if you want, although the basic theme is pretty decent.

There's also WPTouch which looks to be similar in functionality but is a bit more recent and has better administration integration.


Here is a Wordpress plugin which serves different themes to different browsers (e.g. iPhone):

http://code.kuederle.com/browserbasedthemes