stanleystone69x Posted April 22, 2015 Share Posted April 22, 2015 How can i Add Screen Resolution to PHP Variable and Echo it? i am quite confused on how to do this as getting resolution is done in javascript right? Please help me with this. i have coded my first wordpress theme and this is the only part i am stuck at p.s. I want to save screen height in different variable and screen width in different variable. Quote Link to comment Share on other sites More sharing options...
joel24 Posted April 22, 2015 Share Posted April 22, 2015 you need to use javascript to get the the resolution... you'd have to get it, send it via ajax and all kinds of messy code scenarios. Do you need to know it before the template loads? Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted April 22, 2015 Share Posted April 22, 2015 (edited) You've probably already considered this, but have you looked into CSS media queries? They can be used to format the page after the fact based on the screen size. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries Edited April 22, 2015 by cyberRobot Quote Link to comment Share on other sites More sharing options...
stanleystone69x Posted April 23, 2015 Author Share Posted April 23, 2015 Yes i do, this wp theme i made its a wallpaper site theme : http://wpthemetest.in : see the top right corner. "Your Desktop : 1920 x 1080" i want to make this display the actual resolution of the user, currently it is showing just static text. also once i am able to add width and height to php variable i will be able to use those value in wallpaper download option too. can you please write me the code for this if its not too long, i would really appreciate that you need to use javascript to get the the resolution... you'd have to get it, send it via ajax and all kinds of messy code scenarios. Do you need to know it before the template loads? Quote Link to comment Share on other sites More sharing options...
joel24 Posted April 23, 2015 Share Posted April 23, 2015 just use javascript to update the theme when the dom loads, you don't need to know these values in your php script. screen.width; screen.height; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.