It’s pretty hard for PHP to know your screen width. It’s more of a job for jQuery. But your approach seems kind of backward. If the site is supposed to be responsive — why are you trying to deliver different pages to your visitors based on screen width?
It would seem you should handle varying content via media queries.
So if you have 5 pieces of content… let’s say
-
Header A – intended for desktop
-
Header B – intended for mobile
-
Content – same for all
-
Footer A – intended for desktop
-
Footer B – intended for mobile
You would hide the mobile (B) components when screen width is greater than X, and show the desktop (A) components.
Conversely, when screen width is less than X, you would do the opposite: showing mobile components (B) and hiding desktop components (A).
Make sense?
Related Posts:
- pass object/JSON to wp_localize_script
- What is the best practice for customizing a plugin’s JavaScript/jQuery?
- How to Change CSS Variable value in Theme Customizer Live Preview
- How to correctly add JQuery in a WP theme?
- Including Javascript options
- jQuery not available to other scripts
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- My jQuery is enqueued properly. So why isn’t it working?
- How to enqueue scripts properly with ES6 webpack?
- change background image on scroll
- How would I get this to work – send to post from thick box
- FitVid not working for iframes on particular theme install
- Theme now uses require.js and enqueue script no longer works
- can’t add EVENT LISTENER to a element
- jQuery Snippet Not Working on WordPress Site [closed]
- WP Customizer get control value on change
- Execute javscript when theme customizer loads (autosave issue)
- What is the preferred way to add custom javascript files to the site?
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- theme path in javascript file
- How to include jQuery and JavaScript files correctly?
- Solutions for generating dynamic javascript / CSS
- How can I set image sizes and still have responsive images using the srcset attribute?
- Proper, exhaustive documentation for wp.editor etc
- Any alternate TinyMCE4 themes / subthemes?
- jQuery in header or footer
- Is there a way to set the order of wp_footer hooked functions?
- Google Maps not displaying in wordpress using Google Maps Javascript API
- Trigger Customizer saving process with Javascript only
- Excess White Space Above Admin Bar on Frontend Using Twitter Bootstrap
- How to alter the text of the post “Excerpt” box label in WordPress post editor?
- How to Add a .js file Only in one specific Page Dynamically to Head
- Featured Image in 4.4 should be larger on mobile device
- How to use the responsive images feature from WP 4.4 in your themes
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Changing the entire control choices using wp.customize with JavaScript
- Check javascript file Proper way in functions.php
- WordPress Google Maps in Custom Theme
- Modifying JS files in Child-theme
- wp_enqueue_script being ignored in custom theme
- Whats the safest way to output custom JavaScript and Css code entered by the admin in the Theme Settings?
- WordPress Customizer Control with React
- Getting jquery to work with custom theme
- How to configure wordpress to work with Vuejs with SSR and without hashbang
- How to hook CSS file according to theme selection in the customizer section
- Adding wp_enqueue_media(); causes problem
- using wordpress without javascript
- What tags should be used for themes to show the type of layout?
- Toggle Sidebar Display
- Unhook jQuery from WooCommerce via `functions.php`? [closed]
- Fancy-box Esay wordpress plugin fails to work on Multilingual site
- Meta tag viewport
- Can’t show custom post thumbnail sizes as background images
- WP 3.1 upgrade breaks AutoFocus+ theme
- How to make wordpress theme iframe responsive
- JavaScript Change focus to password field login page being reset
- Difficulty loading jQuery with wp_enqueue_script
- My javascript jquery won’t work?
- How to make Isotope and WordPress work together?
- Single page site with history.js
- Implementing FancyBox
- How to add material design css in wordpress and woocommerce
- Use second time navigation.js in underscores [closed]
- Theme Javascript.php Overwritten Nightly [closed]
- Menu jumping when calling it via PHP
- Responsive Images – crop don’t seem to work
- How to get javascript slider to work! [closed]
- Theme Customizer not loading JS for live preview
- Post thumbnail to append post content via ajax click event
- Would to use AJAX to get an option from the database and use it in a jquery setup or is there an alternative to consider?
- Using page-id-{ID} from body_class() in local dev, versus live staging
- Custom theme, contact form 7 & fast secure form doesn’t work
- Enqueued JavaScript is not working
- Custom image size vs CSS sizing
- Change Responsive Images Maximum Width of 1600px
- Javascipt issue on custom theme
- How to make javascript work on theme options page
- How to register and enqueue JavaScript files without breaking plugin dependencies?
- wp_enqueue_script not working?
- JQuery undefined and Stylesheet loads in bottom along with js files
- Weirdness in jQuery supplied with WordPress
- How can I wrap all blog posts image with
- White screen when attaching css to function.php
- WordPress theme resource won’t load over VPN
- pass wordpress template directory into ajax url call
- theme-independent CSS/JS files
- jQuery from parent theme loaded with many other scripts in a single min.js file
- Javascript development in Custom Themes
- Trouble in enquing all js files under certain directory
- add jquery file if a certain page is included
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- How do I implement jPanelMenu?
- Change Image Sizes for Mobile Theme
- loading javascript after jquery is loaded
- MapPress Easy Google Map in Jquery Tabs Problem
- enqueuing external and internal js and css in wordpress did not work with owl.js animate.css
- I don’t think WordPress is loading jquery or bootstrap js
- getBoundingClientRect() showing different values on load vs scroll
- wordpress script_loader_tag in function.php
- How to diagnose wp-env environment problem