Community Forums › Forums › Archived Forums › Design Tips and Tricks › mobile detect redirect
- This topic has 6 replies, 3 voices, and was last updated 9 years, 10 months ago by
CynthiaC.
-
AuthorPosts
-
May 19, 2013 at 11:26 am #41623
CynthiaC
ParticipantI am using the "News" responsive theme and would like to develop a simple 'home page' using the Landing Page feature that will ONLY be the home page when it detects a mobile browser.
Eg:
laptop will go to http://www.mywebsite.com
mobile device is automatically redirected to http://www.mywebsite.com/mobilehome/
I have found different suggestions on the interweb but rather than muck up some perfectly good code I thought there might be a tried and tested Genesis Fix.
Thank you
May 19, 2013 at 1:14 pm #41643Anita
KeymasterThe problem you may have is that you can define a screen size for the laptop in the media queries, however if other mobile devices are the same size - they too will be taken to that page. Do you want a particular sized device to show that new page?
Love coffee, chocolate and my Bella!
May 19, 2013 at 1:25 pm #41648CynthiaC
ParticipantI would say it would be most useful/practicable for the iphone/android or mini ipad. Everything else would be just fine using the regular home page.
May 19, 2013 at 6:27 pm #41721Anita
KeymasterOkay. Each theme developer codes media queries differently and some add all of them, while some only add a few. It is impossible to really anticipate all mobile devices but they do their best to code for the common ones. For example, some themes have issues with different browser version. The same with mobile devices - they come out with so many so quickly that there's no way to keep up. So... the best thing to do is just try to come as close as reasonably possible.
Brian Gardner wrote this Introduction to Media Queries. Read this and maybe you might see some type of mobile query that fits what you are looking for. Then copy paste it under your media queries and then add the styles in there.
http://www.briangardner.com/media-queries/
Love coffee, chocolate and my Bella!
May 19, 2013 at 7:26 pm #41733CynthiaC
ParticipantThat doesn't quite address the redirect issue.
I would like the website to automatically redirect to a different home page when it detects a mobile device.
Script would be something like this - but hoped for something to put in the function.php file instead?
<script type="text/javascript">
$(document).ready(function(){
if($(window).width() < 600){
window.location.href = "http://mywebsite.com/mobilehome/"
}
});
</script>May 19, 2013 at 8:54 pm #41747Bill Murray
Member@CynthiaC - I think you understand you can't do this with media queries/responsive design.
If you want to redirect mobile users to 1 page, the fastest way to do it would be via UA detection or MIME-type support (such as a check for WML) followed by redirection in your htaccess file (assuming your site is on an Apache server). These methods aren't 100% foolproof, but they are pretty reliable. Your script solution would be another route (you could use Genesis settings to get that into the head of your document). There are also open source PHP libraries, like php-mobile-detect. I think the htaccess route would be the fastest.
While you can do what you want, you might want to pause and ask yourself whether you should do what you want. From an SEO perspective, what you want to do isn't a great SEO strategy. More info here.
Hope that helps.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
May 20, 2013 at 11:54 am #41857CynthiaC
ParticipantThanks to both of you,
Lots of food for thought.
I guess I will set up an 'experimental' site and see what I can come up with.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.