Limit posts when visited with mobile devices
Original answer: You could instead try using MobileESP by downloading https://raw.githubusercontent.com/ahand/mobileesp/master/PHP/mdetect.php to your theme directory and then: function change_limit_mobile( $query ) { if ( $query->is_main_query() ) { require get_stylesheet_directory() . ‘/mdetect.php’; $mdetect = new uagent_info; if ( $mdetect->DetectMobileLong() ) { set_query_var( ‘posts_per_page’, 10 ); } } } Update: the simplest thing is to use wp_is_mobile() … Read more