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 */
}
?>
Related
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 am trying to remove the search link from the Woocommerce handheld footer menu which appears when using a mobile device.
I have tried following the official Woocommerce guide here on Customizing links in the handheld footer menu, but the code doesn't change the behaviour. I have already tried clearing cache, cookies & inprivate browsing to test. Any suggestions why this isn't changing?
Code:
add_filter( 'storefront_handheld_footer_bar_links', 'jk_remove_handheld_footer_links' );
function jk_remove_handheld_footer_links( $links ) {
unset( $links['search'] );
return $links;
}
The above code will work. However, if you are modifying the HTML of storefront_handheld_footer_bar_links anywhere else in your Woocommerce site, this will override and take precedence of the PHP function.
Bear this in mind when trying to modify the above function.
Thanks #Orlando P. for help in debugging.
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
I have done quite a bit of googling and have not found a simple solution for a method or a plugin to simply load a different static homepage for mobile devices. Is there a way to do this or a plugin that will do this (without revamping the whole site for mobile devices, as the mobile site style is good, but the specific static homepage is the only thing that I need changed). Wordpress CMS is the platform.
Thanks in advance!
Update:
So I installed the plugin suggested below, copied over an exact copy of the theme I am using but named it with 'mobile' in front just for reference, other than that everything is exactly the same. I read via google that I could add the following code into the functions.php theme file but it just shows up blank when I add the specific code. Code:
//Set Homepage
$mobilehome = get_page_by_title( 'mobilehome' );
update_option( 'page_on_front', $mobilehome->ID );
update_option( 'show_on_front', 'page' );
// Set the blog page
$blog = get_page_by_title( 'Blog' );
update_option( 'page_for_posts', $blog->ID );
Update 2, solved.
I found a simple solution. I created a new theme file 'page-home.php' and changed the css class '#primary' to '#primary-home', then went into the style.css file and added all '#primary-home' css attributes to match '#primary', except on the mobile CSS area of the stylesheet, I added "display:none;" to #primary-home. So now it just doesn't display the homepage on mobile devices, all other pages work (whole point in making the new template page and CSS attribute). I know this fix is probably the simple easy fix but it worked for me!
I found a simple solution. I created a new theme file 'page-home.php' and changed the css class '#primary' to '#primary-home', then went into the style.css file and added all '#primary-home' css attributes to match '#primary', except on the mobile CSS area of the stylesheet, I added "display:none;" to #primary-home. So now it just doesn't display the homepage on mobile devices, all other pages work (whole point in making the new template page and CSS attribute). I know this fix is probably the simple easy fix but it worked for me!
I think that this is as simple as it could get:
Try this plugin - UserAgent Theme Switcher
It will use the user-agent to detect which browser you are on, in this case it could be something like mobile safari or android, etc... then serve the theme based on that.
This could be a hit or miss because you might want or not to change the theme. A more advanced way to do this would be to use a jQuery plugin that checks for the user agent and lets you "do stuff" after you detect it, in this case it could serve as another page or change some CSS.
It's easy and no need to code everything. Install "Redirection" plugin from wordpress repository.
Go to the settings page.
Enter the "Source URL" with your default desktop's homepage
On the "Match" option, select "URL and user agent" & on the "Action" option select "Redirect to URL". Click "Add Redirection".
New configuration option will be appeared. Give any title you want. The "Source URL" must be blank (means that is your base homepage). On the "User Agent" option, choose whether iPhone or Android. On the "Matched" option, set the redirection you want for the mobile homepage.
Done!
You surely can differentiate the homepage on desktop and mobile device based on the redirection you have set before with that plugin. However, you cannot have same url name (ex: www.abcde.com for desktop & www.abcde.com/mobilehomepage for mobile device).
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"