Direct iPhone visitors to different stylesheet?
Is there a method whereby I can employ a different stylesheet (different to the style.css in my child theme) to visitors viewing on the iPhone?
Is there a method whereby I can employ a different stylesheet (different to the style.css in my child theme) to visitors viewing on the iPhone?
There is a global $is_iphone
variable, which you can check against in your code.
global $is_iphone;
if ( $is_iphone ) {
// do something if $is_iphone is true
}
In the realm of your style.css
however, I think @media
queries may be easier. style.css
is hard-coded as a required stylesheet, and there are no filters which can alter what the default stylesheet name is.
You can definitely use it for secondary stylesheets, however.
function my_iphone_styles() {
global $is_iphone;
if ( $is_iphone ) {
wp_enqueue_style( 'my-iphone-styles', get_stylesheet_directory_uri() . '/css/iphone.css' );
}
}
add_action( 'wp_enqueue_scripts', 'my_iphone_styles' );
Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.