- This topic has 3 replies, 2 voices, and was last updated 8 years, 4 months ago by .
- The forum ‘General Discussion’ is closed to new topics and replies.
These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.
Hi, does anyone know how to do this?
I would like to run code via functions.php depending on the display resolution.
For example, if I use Brian Gardner's new mobile first theme I might want to show a slider only on displays above 800px wide.
I don't want to set display:none in the CSS for the slider at lower resolutions as that would defeat the point of a mobile first theme. The slider code would only run at higher resolutions.
I know there is a plugin which adds a body class for the device it thinks the user is on. Maybe I could use some sort of conditional code based on a displayed desktop class. If so, how would I do that?
I don't know of a plugin to add a body class for display resolutions or even if that would be the answer to my problem.
Thing out loud, maybe I don't need to add a body class if I use wp_is_mobile.
If I used something like if ( !wp_is_mobile() ) perhaps I could add some code to a hook which would only work on desktop displays - or at least larger than tablet. Which is the behaviour I want.
Would that work? Or is it a bad idea for any reason?
© 2023 WPEngine, Inc.