I woke up this morning with a thought. Is it a good idea to split the different media queries in different files, check the width of the page in functions.php and then with an IF call the "correct" using wp_register_style and wp_enqueue_style?


There are no functions in wordpress that checks or determine screen sizes. These are all browser related stuff that has got nothing to do with wordpress. There are jquery functions that can maybe work, but again, this is not wordpress related. wp_is_mobile can be used to load stuff conditionally for mobile phones, but then again, wp_is_mobile don't have the logic determining screen sizes, it also can't differentiate between things like mobile phones and tablets.

Your solution here is to do it old school, using media queries in your main stylesheet as done in all of the default themes shipped with wordpress.

Closing off, I would most probably think that if there was such functions to determine screen sizes in wordpress, that it would be completely overrated and useless and time wasting just to load something simple like a stylesheet

  • Hahaha, such thoughs are never BAD. Glad I could help though – Pieter Goosen Apr 25 '14 at 11:16
  • It was to keep the code more clean! :) Thank you again and not have 200000 lines in one css file – Mark Apr 25 '14 at 11:36

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.