"events_get_listview_link" leads to "Page Not Found"

Home Forums Calendar Products Events Calendar PRO "events_get_listview_link" leads to "Page Not Found"

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1067019
    Erik
    Participant

    Hi!

    Im using the script below in my functions.php to show listview for mobile users and calendarview for desktop users.

    The script seems to correctly determine if I’m on a mobile or on a desktop but there’s an issue with the redirect.

    If I use “wp_redirect( events_get_listview_link() );” I get Page Not Found (on my mobile)
    If I use “wp_redirect( ‘http://www.google.se/’ ); I’m correctly redirected to google (on my mobile)

    I’m using Events Calendar. Not Events Calendar PRO.

    SCRIPT:

    /*
    * 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( events_get_listview_link() );
    wp_redirect( ‘http://www.google.se/’ );
    exit();
    }
    }

    #1067357
    Cliff
    Member

    Hi Erik.

    If I understand your question correctly, you’ve moved from The Events Calendar v3 to v4.

    In the current version of our plugins, tribe_get_listview_link() is the correct function to use instead of events_get_listview_link(), which has been deprecated.

    Could you please update your code and if it’s still happening, please tell me the URL that is a 404?

    Thank you.

    #1067423
    Erik
    Participant

    Hi Cliff,

    Unfortunately it doesnt work with tribe_get_listview_link() either. I missed to mention that that was the redirect I initialy tried to use.

    This is what the code looks like right now in my functions.php:

    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() );
    //wp_redirect( ‘http://www.google.se/’ );
    exit();
    }
    }

    And this is the URL (with the “page not found” in mobile):

    http://www.delsbo.org/events/

    /Erik

    #1067439
    Cliff
    Member

    I added this to my local testing site — notice 1==1 instead of wp_is_mobile() just for testing — and when I visited /events/month, it redirected me to /events/list, which I believe is correct behavior for the code:

    add_action( 'template_redirect', 'tec_mobile_template_redirect' );
    function tec_mobile_template_redirect() {
    if( tribe_is_month() && 1==1 ) {
    wp_redirect( tribe_get_listview_link() );
    exit();
    }
    }

    Please try it with the 1==1 instead of wp_is_mobile(). If that solves it, you’ll need to troubleshoot why the issue with wp_is_mobile() — possibly needing earlier add_action priority?

    If the 1==1 code does NOT work, please keep it in your child theme’s functions.php and then follow our Testing for Conflicts Guide (basically deactivating all active plugins besides ones from Modern Tribe) and see if that helps narrow down the cause of this.

    Let us know what you find out.

    Thanks.

    #1067453
    Erik
    Participant

    Hi Cliff,

    Thanks for your suggestion. I have added your code-snippet but still no change.

    When I, for testing, use a common “wp_redirect( ‘http://www.google.se/’ );” in the snippet, the user is correctly redirected in mobile mode and not in desktop This must mean that the “wp_is_mobile” is working correctly. In other words, I belive it’s the “tribe_get_listview_link()” that does not work as expected.

    /Erik

    #1067673
    Erik
    Participant

    Hi Cliff,

    The “tribe_get_listview_link()” didn’t work since listview was not activated in the calendar settings. This resolves my main question but I still have one minor detailed that you might give me a suggestion for…

    Since I had to activate the listview, the view-menu/dropdown now appears. Thats fine, but in my mobile view the script prevents users to accually choose the calendar view. I therefore would like it to be hidden in mobile view. How might I acchive that?

    Thanks for your support.

    /Erik

    #1067773
    Cliff
    Member

    Ah ha! Had to enable List View 🙂

    You could add this CSS only for mobile (either inject if true === wp_is_mobile() or just via media queries):

    body.post-type-archive-tribe_events #tribe-bar-views { display: none; }

    I hope that helps.

    #1079910
    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 8 posts - 1 through 8 (of 8 total)
  • The topic ‘"events_get_listview_link" leads to "Page Not Found"’ is closed to new replies.