Okay
  Public Ticket #3813850
Redirection links to mobile works only once
Closed

Comments

  • Chaymae started the conversation

    Hi, the code below was added by my colleage to redirect page mobile pages as some of the designs such us Montoya moving grid are not responsive and do not display in the same manner as in desktop. However the redirection only works in the beggining and after few hours, not at all. Here is the code added in php.functions:

    // FOR MOBILE REDIRECT
    add_action( 'template_redirect', 'redirect_on_mobile_page' );
    function redirect_on_mobile_page(){
               if ( wp_is_mobile() && is_front_page() ) {
               wp_redirect(home_url('/hpmobile'));
                  exit;
                  }
               }
    function redirect_about_to_mobileabout() {
        // Check if the user is on the "About" page
        if (is_page('about')) {
            // Detect if the user is on a mobile device
            if (wp_is_mobile()) {
                // Redirect to the "MobileAbout" page
                wp_redirect(home_url('/aboutm'));
                exit;
            }
        }
    }
    add_action('template_redirect', 'redirect_about_to_mobileabout');

    ?>


  •  2,024
    Support replied

    Try the following:

    • refresh the permalinks in settings -> permalinks
    • try temporarily disabling ajax in customizer -> general settings and test again. it's the wp_redirect that I'm suspecting may cause pbs