Get Upcoming Date of Single Recurring Event

Home Forums Calendar Products Events Calendar PRO Get Upcoming Date of Single Recurring Event

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1017946
    Our Saviors Church
    Participant

    I’m trying to list just the date of a specific event on a page template, but I can’t quite figure out how. If I could get the event by ID, that would be great, or I could isolate it using the tag AND category. I’ve tried following along from this article to using the tag like so:

    
    // Ensure the global $post variable is in scope
    global $post;
     
    // Retrieve the next 5 upcoming events
    $events = tribe_get_events( array(
    'eventDisplay'	 => 'upcoming',
    'posts_per_page' => 1,
    'tax_query'=> array( 'taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => 'lafayette' ),
    'tag' => 'Step One'
    ) );
    
    foreach ( $events as $post ) {
    setup_postdata( $post );
        echo tribe_get_start_date();
    }
    

    But that’s not working, it’s not returning any results. I’ve tried it with and without the tax_query line setting the category. Any advice on a good way to do this? Again, just need the next upcoming date for a specific recurring event.

    #1017982
    Our Saviors Church
    Participant

    I think I fixed it myself, but I’d love to verify with someone that this is the best way to do this.

    
    <?php
    global $post;
    
    $events = tribe_get_events( array(
    'eventDisplay'	 => 'upcoming',
    'posts_per_page' => 1,
    'tribe_events_cat' => 'lafayette',
    'tag' => 'step-one'
    ) );
    foreach ( $events as $post ) {
    setup_postdata( $post );
    
    echo tribe_get_start_date($event, '', 'F j');
    }
    ?>
    
    #1018004
    George
    Participant

    I’m sorry @Tyler, but we cannot offer any support with custom code here 🙁

    I will close this ticket for now – if your second code example works well for you, keep using that!

    Sincerely,
    George

    #1018006
    George
    Participant

    P.S.

    For what it’s worth, just to help a little bit here, your second solution is correct. I would personally recommend this instead to reduce chance of conflict with the unnecessary loading of the $post global:


    <?php

    $events = tribe_get_events( array(
    'eventDisplay'=> 'upcoming',
    'posts_per_page' => 1,
    'tribe_events_cat' => 'lafayette',
    'tag' => 'step-one'
    ) );

    foreach ( $events as $event ) {
    echo tribe_get_start_date( $event, '', 'F j' );
    }
    ?>

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Get Upcoming Date of Single Recurring Event’ is closed to new replies.