Home › Forums › Calendar Products › Events Calendar PRO › Force list view on mobile, but not iPad
- This topic has 2 replies, 3 voices, and was last updated 8 years, 7 months ago by Support Droid.
-
AuthorPosts
-
September 19, 2015 at 4:31 am #1006753KevinParticipant
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();
}
}September 21, 2015 at 8:30 am #1007053GeoffMemberHey Kevin and welcome to the forums!
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.
Will this work for you? Please let me know.
Thanks!
GeoffOctober 6, 2015 at 7:05 am #1011860Support DroidKeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Force list view on mobile, but not iPad’ is closed to new replies.