function is_ios_device() { return preg_match('/iPhone|iPod|iPad/', $_SERVER['HTTP_USER_AGENT']); } function is_android_device() { return preg_match('/android/i', $_SERVER['HTTP_USER_AGENT']); } function redirect_if_desktop() { if (!is_ios_device() && !is_android_device() && is_page(XXX) && !is_user_logged_in()) { wp_redirect(home_url()); exit; } } add_action('template_redirect', 'redirect_if_desktop'); function redirect_if_ios_mobile() { if (is_ios_device() && is_page(XXX) && !is_user_logged_in()) { wp_redirect('https://apps.apple.com/......'); exit; } } add_action('template_redirect', 'redirect_if_ios_mobile'); function redirect_if_android_devices() { if (is_android_device() && is_page(XXX) && !is_user_logged_in()) { wp_redirect('https://play.google.com/store/.....'); exit; } } add_action('template_redirect', 'redirect_if_android_devices');