Force list view on mobile, but not iPad

Home Forums Calendar Products Events Calendar PRO Force list view on mobile, but not iPad

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1006753
    Kevin
    Participant

    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();
    }
    }

    • This topic was modified 8 years, 7 months ago by Kevin.
    • This topic was modified 8 years, 7 months ago by Kevin.
    • This topic was modified 8 years, 7 months ago by Geoff.
    #1007053
    Geoff
    Member

    Hey 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!
    Geoff

    #1011860
    Support Droid
    Keymaster

    This 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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Force list view on mobile, but not iPad’ is closed to new replies.