1

My desktop version of wordpress theme requires using a 'static' page as the start page as it has custom shortcodes etc.

While this is good, when it comes to my mobile theme, sadly the 'static' page is being displayed and because its a different theme, the shortcodes are not being executed.

Is there a way to tell a mobile theme to display 'blog posts' as the default page and not use a 'static page' as a starting page for the theme?

2
  • Thanks Kaiser, pardon me, but am I right in assuming that this goes into the mobile theme's header (even before the <head> tag)?
    – Sledge81
    Apr 23, 2012 at 16:49
  • What? Please ask Q on my answer. Thx.
    – kaiser
    Apr 24, 2012 at 14:23

1 Answer 1

3

Just wrap you code up in a conditional:

if ( $GLOBALS['is_iphone'] )
{
    // do funky stuff for mini screens
}

global $is_iphone; will trigger TRUE for all mobile devices incl. tablets.

Edit for WP 3.4+

Now there's wp_is_mobile() to make checks for User-Agent. It's basically a wrapper for $is_iphone and does the same.

2
  • 1
    Is this a built-in WordPress variable? If so, this might be easier than the way I am doing it now (and was going to suggest) which is by including MobileDetect. Apr 23, 2012 at 16:48
  • 1
    Yes it is. There'll also be a function wrapper or short API for it with WP 3.4.
    – kaiser
    Apr 23, 2012 at 17:38

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.