0

Can you automatically change to a static page if access to the site is via mobile device?

Currently my homepage is static and use components that do not work properly with mobile devices but are are necessary for the desktop version. I want to create another static page that will be displayed in the case of mobile devices.

I have tried using the code WP Moving but I could not.

Thanks for any suggestions.

  • There is no reliable way server side to do this. You are going to serve the wrong page to some users no matter what you try. Your whole project relies on client side processes which is never reliable. You need to look into wp_is_mobile() or some other mobile switchers, but be warned, as I said, these relies on client side processes and WILL fail for some users which will show incorrect data to them – Pieter Goosen Jan 19 '16 at 10:06
  • Thk, i use this:<?php if ( wp_is_mobile() && is_front_page() ) { wp_redirect( 'example.com', 301 ); exit; } ?> – Die84albe Jan 19 '16 at 10:35
0

I used this:

<?php if ( wp_is_mobile() && is_front_page() ) {
    wp_redirect( 'http://www.example.com', 301 ); exit;
} ?>

in header.php of theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.