Some tablets may load the desktop version of the website instead of the mobile version.
This can happen because modern tablets often report themselves to the browser as desktop devices. When this happens, WordPress does not detect them as mobile devices, so WPRentals loads the desktop search layout instead of the mobile search layout.
This is common on:
- iPad devices using Safari
- Large Samsung or Android tablets using Chrome
- Tablets with “Request Desktop Site” enabled
- Desktop browser tests where the window is only resized smaller
Resizing a laptop or desktop browser window is not the same as testing on a real tablet. A laptop still has mouse or trackpad support, so it can still be detected as a desktop device.
Why Does This Happen?
WPRentals uses WordPress mobile detection to decide when to show the mobile search.
Some tablets do not send a mobile signal anymore. For example, iPadOS Safari may identify itself as a Mac desktop browser, and some Android tablets may identify themselves as desktop Linux or Chrome browsers.
Because of this, the site cannot always know that the visitor is using a tablet.
How to Fix It
A workaround is to detect the device by hardware behavior instead of device name.
The code below checks if the device has a touchscreen and a tablet-size screen width. If yes, it treats the device as mobile for the WPRentals mobile search.
Add this code in the child theme functions.php file, or ask your developer to add it.
<?php
/**
* Show the mobile advanced search on tablets that report themselves as desktop,
* such as iPadOS Safari, Android tablets in desktop mode, or "Request desktop site".
* Detection is based on actual hardware: touch pointer + tablet-width screen.
*/
/**
* Treat detected tablet as mobile.
*/
add_filter( 'wp_is_mobile', function ( $is_mobile ) {
return $is_mobile || ! empty( $_COOKIE['wprentals_is_tablet'] );
} );
/**
* Detect tablet in the browser and store the result in a cookie.
*/
add_action( 'wp_head', function () {
$server_mobile = wp_is_mobile() ? 1 : 0;
?>
<script>
(function () {
try {
var isTablet =
window.matchMedia('(pointer: coarse) and (hover: none)').matches &&
window.innerWidth >= 600 &&
window.innerWidth < 1200;
var hasCookie = document.cookie.indexOf('wprentals_is_tablet=1') !== -1;
if (isTablet && !hasCookie) {
document.cookie = 'wprentals_is_tablet=1; path=/; max-age=31536000; SameSite=Lax';
if (!<?php echo (int) $server_mobile; ?>) {
location.reload();
}
} else if (!isTablet && hasCookie) {
document.cookie = 'wprentals_is_tablet=; path=/; max-age=0; SameSite=Lax';
if (<?php echo (int) $server_mobile; ?>) {
location.reload();
}
}
} catch (e) {}
})();
</script>
<?php
}, 1 );
What Should Happen After Adding the Code?
On affected tablets, the first page load may refresh once automatically. After that, the mobile search should appear normally.
Real desktop and laptop devices should not be affected.
What If the Issue Continues on One Device?
Open this link on the affected device:
https://www.whatismybrowser.com/detect/what-is-my-user-agent/
Copy the user agent and send it to support. This helps us check how that device identifies itself to the website.
Important Notes
Add the code in a child theme or a small custom plugin. Do not add it directly in the main WPRentals theme files, because a future theme update can overwrite the change.
This workaround is needed only for tablets that identify themselves as desktop devices.