Home › Forums › Calendar Products › Events Calendar PRO › Grabbing Venue City in Loop
- This topic has 5 replies, 4 voices, and was last updated 9 years, 7 months ago by
roje0913.
-
AuthorPosts
-
August 23, 2016 at 12:07 pm #1154973
roje0913
ParticipantI 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.
August 23, 2016 at 4:01 pm #1155105Nico
MemberHi 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,
NicoAugust 23, 2016 at 4:17 pm #1155116roje0913
ParticipantThis reply is private.
-
This reply was modified 9 years, 8 months ago by
roje0913. Reason: making sure the code was set to 'code' tags
August 24, 2016 at 6:54 pm #1155621Nico
MemberThanks 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,
NicoSeptember 15, 2016 at 9:35 am #1164663Support Droid
KeymasterHey 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 -
This reply was modified 9 years, 8 months ago by
-
AuthorPosts
- The topic ‘Grabbing Venue City in Loop’ is closed to new replies.
