I'm using the Genesis Framework, static page, with Soliloquy slider on the home page only. We would like to prevent the slider to load on mobile device to reduce load time.
Any way to do that ? Basically I need to know how to disable some PHP when a mobile device is detected.
<?php if ( !wp_is_mobile() ) {
/* Show Slider here */
} ?
Refer HEre Wp Is mobile
Related
I'm using the Genesis Framework on my website. I disabled the dashicons from loading on the front-end using the code below in my functions.php file:
function wpdocs_dequeue_dashicon() {
if (current_user_can( 'update_core' )) {
return;
}
wp_deregister_style('dashicons');
}
add_action( 'wp_enqueue_scripts', 'wpdocs_dequeue_dashicon' );
but i noticed my mobile/tablet views are now missing icons. More particularly, the hamburger menu and the down arrow for a dropdown.
Here's how it looks like --> https://www.dropbox.com/s/7azuj6vraehzll5/dashicons.png?dl=0
I'm not using the dashicons on my desktop version that's why i disabled it (because it's causing my site to load slowly using website speed tests).
Is there a way to load dashicons only on mobile? Or at least those two icons? or via css? I can't seem to find any. All my googling shows me how to add them (which i don't).
The only reason I want them to load on mobile is to the hamburger menu icon and a down arrow is the best representation that that's a menu and an option avaialable.
I've searched so much that my brain is starting to hurt. Basically, I would like for the button on my site to open a YouTube video on mobile. On desktop, it will open up a lightbox and a simple embed that autoplays. I've read that mobile devices won't allow autoplay because it eats up data. If the user is choosing a button ('Watch Now', 'Watch Video', etc.) is that not a choice to use data? Is there really no way to do an .onClick parameter?
Thanks for any help!
Use the wordpress function wp_is_mobile().
if ( wp_is_mobile() ) {
/* Display and echo for mobile specific stuff here */
}else{
/* Display and echo for Desktop */
}
Read more about this function https://developer.wordpress.org/reference/functions/wp_is_mobile/
I have a doubt about WordPress. I know that is possible to hide a page in WordPress, but I would like to know if there is some code to show this page only to mobile devices and hide it from PC.
I would like to hide the page "subir captura" because I have a button for this function, but that button doesn't work in mobile devices, so I want to use the page, but hide it from PC.
https://i.gyazo.com/b5cd9c500ddbcaaf592cd057e183e69f.png
You can use the WP Mobile Detect plugin to accomplish a variety of different user agent tests. Use the wpmd_is_notdevice() conditional to test for desktops.
You have to use wordpress is mobile function like this:
<?php
if( !wp_is_mobile() ){
/* Display and echo mobile specific stuff here */
}
?>
I created a child theme of the TwentyTwelve theme in Wordpress for my photography website.
In the photo gallery pages, clicking on a thumbnail image either triggers Fancybox or Photoswipe, depending on the screen size (if <500px Photoswipe is used as it's probably a mobile device).
For better performance I would like to load only the required javascript, Fancybox or Photoswipe, but not both of them.
I'm not using plugins for Fancybox/Photoswipe but load them in the child theme functions.php using wp_enqueue_style and wp_enqueue_script
the choice between Fancybox/Photoswipe is made in another javascript file, also enqueued in functions.php: according to the result of jQuery(window).width(); it triggers either Fancybox or Photoswipe on certain elements:
jQuery(document).ready(function() {
windows_size = jQuery(window).width();
if( windows_size > 500) { // Load Fancybox
jQuery(".brick a").fancybox({
[...]
else { // Load Photoswipe
jQuery(".brick a").photoSwipe({
[...]
I cannot use any of the WP functions like is_page(...), as both scripts are fired on the same page
I don't know if it would be possible, using Wordpress, to load all required files for Photoswipe (js and css) in the javascript above
I'd rather not use the user-agent to detect a mobile device
I searched on Google and on StackOverflow but couldn't find any answer specifically related to Wordpress and this situation.
Thanks for your help.
I saw this the other day, and it looks like he's trying to do the same thing as you -- "How to load JavaScript conditionally with media queries in WordPress":
http://blog.logo24.com/2013/07/23/javascript-media-queries-wordpress/
His solution is JavaScript, rather than PHP, and comes with some caveats.
I want to switch my mobile site to main site. remember when you open facebook on mobile then view of facebook in mobile version is change and when you click on "Go to main site" then it appears main site in mobile. that i want.
And also main problem is both links are same means
main site url is http://www.yousite.com
mobile site url is http://www.yousite.com
when you open in mobile then mobile template is show and when i open is desktop then main site template is show.
I've done this on a previous version of my site and wrote about it here: http://arleym.com/mobile-device-detection-redirection/
Basically I have some device detection that will be ignored if there is a query string. So the "view desktop version" link will avoid the detection/redirection and give the user a cookie.
I used this detection script: http://detectmobilebrowsers.mobi/
and modified my switch like so:
<?php
if(isset($_GET['switch'])){
setcookie('switch',$_GET['switch']); // set a cookie
}
if(!isset($_GET['switch']) && !isset($_COOKIE['switch'])){
require_once('/server/path/arleym.com/mobile_device_detect.php'); //Andy Moore's script
mobile_device_detect(true,false,true,true,true,true,true,'
http://arley.me',false);
}
?>
The view desktop url simply does its thing like href="http://whatever.com?switch=0"