On the forums, I found a way to force the list view on mobile (see code at bottom), but there are two problems with this implementation. First is that iPads are targeted with this code (which I do not want), and second, it is not possible to switch to month view on mobile devices when this code is in place (it just reverts back to list).. I am looking for a solution that targets mobile devices smaller than a specific pixel size and allows switching to month view, if desired.
Here is the aforementioned code:
/*
* The Events Calendar – Redirect Mobile Users to List View
* @version 3.9
*
* @link http://theeventscalendar.com/support/forums/topic/forcing-list-view-on-mobile-only/
*/
add_action( ‘template_redirect’, ‘tec_mobile_template_redirect’ );
function tec_mobile_template_redirect() {
if( tribe_is_month() && wp_is_mobile() ) {
wp_redirect( tribe_get_listview_link() );
exit();
}
}
Good question. That snippet is a good one for sure, but you’ve already noted the limitations–namely, that the breakpoint is established by WP’s definition of mobile and that it redirects the template to list view as a whole.
Another approach is the one outlined in this tutorial. You get to specify the exact point and which the transition happens and it doesn’t force any template redirects.