Problem with start_date in tribe_get_events in 2.0.4

Home Forums Calendar Products Events Calendar PRO Problem with start_date in tribe_get_events in 2.0.4

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #16808
    Mike
    Participant

    I’ve tried hacking it from a number of directions, but the start_date parameter in tribe_get_events() always returns the current date.
    Here’s code I’ve been using:

    global $post;
    $current_date = date(‘j M Y’,strtotime(‘1 day’));
    $end_date = date(‘j M Y’, strtotime(‘7 days’));
    $all_events = tribe_get_events(
    array(
    ‘start_date’=>$current_date,
    ‘end_date’=>$end_date,
    ‘eventDisplay’=>’upcoming’,
    ‘posts_per_page’=>10,
    ‘tax_query’=> array(
    array(
    ‘taxonomy’ => ‘tribe_events_cat’,
    ‘field’ => ‘slug’,
    ‘terms’ => ‘theater’
    )
    )
    )
    );

    #16823
    Rob
    Member

    Hey Mike. Thanks for the heads up here; let me get Jonah to double check here, as this is a bit outside my area of expertise. Sit tight and he’ll respond when he hits the forums next!

    #16843
    Jonah
    Participant

    Hi Mike, the above code works for me once I take out the tax_query – are you sure you have an event within that range in that category?

    #17149
    Mike
    Participant

    Jonah, I’m running in a sandbox now, so I’ve entered in specific events in advance to test things out – so I did have ‘theater’ terms events. Taking out the tax_query, I now get everything, but the start_date is not advancing one day as the strtotime() function says it should.

    Thoughts?

    #17340
    Jonah
    Participant

    Hi Mike, not sure what the issue could be with the query, it works fine for me with the start_date/end_date args. Do you have any other code that could be conflicting with this query? Can you paste your full custom query code into http://pastie.org/pastes/new ?

    #17524
    Mike
    Participant

    Jonah, here’s the original code:
    http://pastie.org/3720843
    Strange, but now the tax_query works, but the $currentdate still does not advance with the strtotime() modifier.
    Thanks for your help!

    #17533
    Jonah
    Participant

    Well, glad to hear the tax_query works! Not sure what could be going on with the strtotime() modifier. Maybe a plugin or theme conflict or server/PHP issue?

    #17535
    Mike
    Participant

    The thing is, that strtotime() works in the $end_date but not $start_date. Any thoughts?

    #17537
    Jonah
    Participant

    No idea Mike, like I said it works fine for me.

    #18749

    I’m having the same problem with this. I’m letting the user choose a date ranger with the jQuery UI datepicker. Printing out all the values, they all look good. It just seems like how the tribe class parses the date, it automatically overrides it and puts in the current date.

    #18759

    Maybe this is due to the fact that somewhere in the callstack the property ‘upcoming’ is getting flagged and then returning todays date?

    #18806

    I think I was right about my hunch that the eventDisplay property of ‘upcoming’ was nerfing the start_date selector from the tribe_get_events method. I would recommend classifying that as a bug and fixing it in an upcoming release. In the meantime, here is a workaround using WP_QUERY:

    Pretty source:
    http://pastebin.com/fgpC2ND1

    Probably pretty ugly source:
    query(
    array(
    ‘post_type’ => ‘tribe_events’,
    ‘posts_per_page’ => -1,
    ‘orderby’ => ‘meta_value’,
    ‘order’ => ‘ASC’,
    ‘meta_key’ => ‘_EventStartDate’,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘_EventStartDate’,
    ‘value’ => array( $startDate.’ 00:00:00′, $endDate.’ 23:59:59′),
    ‘type’ => ‘DATETIME’,
    ‘compare’ => ‘BETWEEN’
    )
    )
    )
    );

    if ($featured_query->have_posts()) :
    while ( $featured_query->have_posts() ) : $featured_query->the_post(); ?>

    //DO WHATEVER YOU NEED TO DO WITH THE POSTS HERE

    <?php else: echo ' Sorry, there are no posts for the selected dates.’; ?>

    #18807

    Looks like some of that got cut off. Let me try again:

    query(
    array(
    ‘post_type’ => ‘tribe_events’,
    ‘posts_per_page’ => -1,
    ‘orderby’ => ‘meta_value’,
    ‘order’ => ‘ASC’,
    ‘meta_key’ => ‘_EventStartDate’,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘_EventStartDate’,
    ‘value’ => array( $startDate.’ 00:00:00′, $endDate.’ 23:59:59′),
    ‘type’ => ‘DATETIME’,
    ‘compare’ => ‘BETWEEN’
    )
    )
    )
    );

    if ($featured_query->have_posts()) :
    while ( $featured_query->have_posts() ) : $featured_query->the_post(); ?>

    //DO WHATEVER YOU NEED TO DO WITH THE POSTS HERE

    <?php else: echo ' Sorry, there are no posts for the selected dates.’; ?>

    #19220
    Rob
    Member

    Hey Kindra. Thanks for the follow-up here. We can definitely take a look at this for you and I apologize for the delay in responding. If this issue persists would you mind dropping the code you’re using into a pastie.org link (or something similar) so we can see it that way? As it stands there isn’t a very good method for sharing code in the forums beyond that…

    Thanks in advance!

    #19526

    I’ve got a solution up and running. You can see the loop code here:

    http://pastebin.com/fgpC2ND1

    Here is the filtering in action on a sandbox development installion:

    http://www.visitoshkosh.com/ocvb/events/

Viewing 15 posts - 1 through 15 (of 17 total)
  • The topic ‘Problem with start_date in tribe_get_events in 2.0.4’ is closed to new replies.