Grabbing Venue City in Loop

Home Forums Calendar Products Events Calendar PRO Grabbing Venue City in Loop

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1154973
    roje0913
    Participant

    I have a function that is grabbing a bunch of meta keys and displaying them in a loop on the home page. I am trying to figure out how to grab the venue city for each of the items. Below is what I can come up with based on your docs, but it keeps coming up blank. The start of the code below has been successful grabbing the start date, end date, and cost.

     $i = 0;
            foreach ($events as $event) {
                           $meta = get_post_meta($event->ID);
    			$localeze =  $meta['_VenueCity'][0];

    I also tried using
    $meta2 = $meta['_EventVenueID'][0];

    This only returned the id number, but it did work.

    #1155105
    Nico
    Member

    Hi there @roje0913,

    Thanks for getting in touch with us! I can help you with your code.

    Can you please follow-up with the complete code? I would like to see how you are getting events.

    Please let me know and I’ll complete the code for you,
    Best,
    Nico

    #1155116
    roje0913
    Participant

    This reply is private.

    • This reply was modified 9 years, 8 months ago by roje0913. Reason: making sure the code was set to 'code' tags
    #1155621
    Nico
    Member

    Thanks for following up with the complete snippet code!

    You can use the tribe_get_city passing the event id as parameter. Internally this function will look for the ‘_VenueCity’ meta just like you are doing which seems to be fine as well, not sure why it’s failing.

    This is the actual function code (the-events-calendar/src/functions/template-tags/venue.php line 201):

    /**
    * City
    *
    * Returns the venue city
    *
    * @param int $postId Can supply either event id or venue id, if none specified, current post is used
    *
    * @return string City
    */
    function tribe_get_city( $postId = null ) {
    $postId = tribe_get_venue_id( $postId );
    $output = esc_html( tribe_get_event_meta( $postId, '_VenueCity', true ) );

    return apply_filters( 'tribe_get_city', $output );
    }

    Give this a try and let me know if it works for you, and make sure the events queried actually have a venue with complete address 😉

    Best,
    Nico

    #1164663
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Grabbing Venue City in Loop’ is closed to new replies.