0

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?

1
  • @media css might be what your looking for – Shawn Jan 21 '14 at 20:52
2

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' );
2
  • 1
    For anybody interested - it looks like WP has a few global browser detection variables: Read Codex – Howdy_McGee Jan 21 '14 at 22:30
  • No problem! Mark this question as answered, to help clean up the amount of unanswered questions out there. :) – Eric Holmes Jan 22 '14 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.