Archived topic
Different home page for mobile device
10 replies · Started by manaadiar on February 2, 2020
Hi Tom, sorry the below code that you suggested (and worked) for other site is not working for me..I am using GP Premium with a child theme..
Can you pls advise..??
add_action( 'wp', 'tu_redirect_mobile' );
function tu_redirect_mobile() {
if ( wp_is_mobile() AND is_front_page() ) {
wp_redirect( 'https://beta.zeine.es/contacto-movil', 301 );
exit;
}
}
I'm marking this resolved as per this:
https://generatepress.com/forums/topic/different-homepage-for-mobile/#post-1152173
Hi Leo, no, it didn't work.. I thought if I use the mobile option in the customize screen and change there, it will work.. But I see it changed the whole home page and i realised that the mobile sign there only "shows" how it will look..
What i want is, currently my home page is https://shippingandfreightresource.com.. I want the home page to show https://shippingandfreightresource.com/mob-home when users are viewing on mobile device..
Hi Leo, no, it didn’t work.. I thought if I use the mobile option in the customize screen and change there, it will work.. But I see it changed the whole home page and i realised that the mobile sign there only “shows” how it will look..
What i want is, currently my home page is https://shippingandfreightresource.com.. I want the home page to show https://shippingandfreightresource.com/mob-home when users are viewing on mobile device..
Hi there,
you will need to use the PHP snippet that Tom provides here to create a redirect for mobiles:
https://generatepress.com/forums/topic/different-homepage-for-mobile/#post-554306
Hi David, i did use it but doesn't seem to work on my site..
How are you adding the code ?
its there in functions.php file
Try adding it using the Code Snippets plugin - if it still doesn't work then some other function must be conflicting with it.
I dont have the code snippets plugin.. Can you suggest any other code..??
Can you disable all other custom functions to test for now?
And make sure to clear and disable the caching plugin during testing.
That code should be correct. It's a WordPress function and not controlled by the theme:
https://developer.wordpress.org/reference/functions/wp_redirect/