Can't get start date outside of loop

WordPress Event Management, Calendars & Registration Forums General Question Can't get start date outside of loop

This topic contains 4 replies, has 2 voices, and was last updated by  Stephen Harris 9 years, 12 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #10765

    I’m trying to use eo_the_start/eo_get_the_start (I have tried both) and can’t get either to work. This is in functions.php

    I have tried

    eo_the_start($date_format, $eid), eo_the_start($date_format, $eid,null,0), and eo_the_start($date_format, $eid, null) in both the_start and get_the_start variations (ideally leaning towards get_the since I’m trying to place it in a variable and echo that later), neither with any results.

    Please help 🙁

    $eid for sure has the right variable, and I have even hard coded the number and it works. Interestingly enough I have even tried useing eo_the_start($date_format, $eid) in event-meta-event-single.php (as both the_start and get_the_start) and it works! I’m getting $eid from a GET parameter and it’s working for other functions that use it, I have even tried casting it to (int) with no luck.

    Halp 🙁

    Gabriel David
    #10766

    P.S. the event is not reoccuring

    • This reply was modified 9 years, 12 months ago by  Gabriel David. Reason: typo
    Gabriel David
    #10768

    P.P.S same is true for the_end

    Gabriel David
    #10769

    Not sure if I answered my own question or not, it seems a bit weird to have an occurrence ID actually set to anything other than 0 given an event is not reoccuring, but the following code gave me the start and end date correctly:

    $occurrences = eo_get_the_occurrences_of( $eid );
    reset($occurrences);
    $first_key = key($occurrences);
    $start = eo_get_the_start('m/d/Y',$eid,null,$first_key);
    $end = eo_get_the_end('m/d/Y',$eid,null,$first_key);

    Where $eid is the event id

    • This reply was modified 9 years, 12 months ago by  Gabriel David.
    • This reply was modified 9 years, 12 months ago by  Gabriel David.
    Gabriel David
    #10775

    Hi Gabriel,

    You can use eo_get_schedule_start(), this works for recurring events and returns the first start date of the event. Otherwise, the method you use above should work fine.

    Stephen Harris
Viewing 5 posts - 1 through 5 (of 5 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.