0

I'm looking for the spot in the Wordpress code where I can put a simple check for the browser type (mobile or not) and include, if it exists, the corresponding mobile.style.css instead of the style.css.

Where do I put code like that? I browsed the code and put it into the get_stylesheet_directory function but that didn't seem to work.

Edit: Why not media queries? Because they don't work as good as expected. I need a mobile layout on my Galaxy Nexus too and that has a resolution of 1280x720. So this tutorials on how to write a mobile css query don't work for me.

So it sucks because any time a new monster resolution tablet/smartphone is released - android, I'm looking at you! - I have to change the code.

schlingel
  • 8,382
  • 7
  • 31
  • 60
  • 2
    Why don't you just use media queries? These are very simple and also help make your website more usable on the desktop as you can change the design based on the browser viewport. – str Feb 05 '13 at 10:55
  • You can find more in this [issue](http://wordpress.stackexchange.com/questions/3875/how-to-detect-mobile-devices-and-present-them-a-specific-theme) – elkebirmed Feb 05 '13 at 11:00
  • @str, good point, please see my comment. – schlingel Feb 05 '13 at 11:10
  • @elkebirmed: I just want to include another CSS i can work on. That should be possible with 20 lines of code instead of installing WPTouch. – schlingel Feb 05 '13 at 11:13

1 Answers1

0

You are approaching this problem in the wrong way. You should use feature detection (http://modernizr.com/) and media queries to provide content differently based on the device size and what it's capable of.

Dean
  • 5,075
  • 2
  • 16
  • 22
  • So it's either CSS media queries (see edit) or JS-code instead of PHP. I don't care about features, I care about the device. – schlingel Feb 05 '13 at 11:12
  • You can detect pixel density too for monster resolution phones using media queries, so that's no excuse. – Dean Feb 05 '13 at 13:08
  • And how do I do that without destroying the desktop CSS? I don't want the same layout for every device with the same density. I need to know the form factor too. – schlingel Feb 05 '13 at 14:53
  • Like so: http://www.broken-links.com/2012/07/13/using-media-queries-to-test-device-resolution/ – Dean Feb 05 '13 at 16:55
  • I really don't see why this JS/CSS hack should be more clean than a PHP hack. If I understand the article right, I'd have to use JS to detect the DPR and create either media queries on the fly or test it with every browser/device I want to support and write a specific query. – schlingel Feb 05 '13 at 17:22
  • Because what happens when you have a new operating system with a new user agent. Media queries cover all cases and futureproof you for variable screen sizes. There are literally thousands of different mobile phones, running hundreds of different operating systems (I'm not not talking just android clones either). – Dean Feb 05 '13 at 17:53