WP Recipes has a neat WordPress trick. Apparently WordPress has a few variables ($is_gecko
, $is_IE
, etc) that are set to either true
or false
depending on which browser a visitor is running. Coupled with the body_class
hook, you can add a class of the browser name to the <body>
tag.
add_filter('body_class','browser_body_class'); function browser_body_class($classes) { global $is_IE, $is_iphone; if ($is_IE) { $classes[] = 'iesux'; } elseif ($is_iphone) { $classes[] = 'iphone'; } else { //let's not add a class for normal browsers... } return $classes; }
This could potentially be useful for fixing those annoying Internet Explorer issues without resorting to CSS hacks.
How to detect the visitor browser within WordPress [WP Recipes]