How do i set a different product per page for desktop/mobile?
At the moment i have this code in functions.php:
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 15 );
function new_loop_shop_per_page( $cols ) {
$cols = 15;
return $cols;
}
But on mobile i want to show 10 products insted of 15 products. Any advice?
3
Answers
You could use the Class here: http://mobiledetect.net/
or write a detection function yourself using $_SERVER[‘HTTP_USER_AGENT’] filtering for known mobile devices.
You can use wp_is_mobile() – Test if the current browser runs on a mobile device (smart phone, tablet, etc.)
So you get:
In the WP documentation there is a way to to check the current browser runs on a mobile device or not.
You can try
wp_is_mobile()
(I didn’t test it myself.)Reference Here