Home › Forums › Calendar Products › Events Calendar PRO › Event custom meta fields for WP_Query
- This topic has 5 replies, 4 voices, and was last updated 9 years, 2 months ago by
Joshua.
-
AuthorPosts
-
February 8, 2017 at 4:37 pm #1231764
Joshua
ParticipantHello,
I couldn’t find this in the docs or elsewhere: is there a list of all of the custom meta fields associated with an event.
I’m using a custom WP_Query and want to grab and display the following:
– start date
– location/address
– description
– excerpt
…etc.How would I go about doing that? I only want some pieces of the event(s) for certain areas which is why I went with using WP_Query.
Is start date just ‘start_date’? And likewise ‘end_date’? What date format id that in or is it a date object at all?
Best,
Joshua
February 9, 2017 at 5:08 pm #1232502Cliff
MemberHi, Joshua.
Please reference these:
- https://theeventscalendar.com/knowledgebase/using-tribe_get_events/
- https://theeventscalendar.com/knowledgebase/custom-event-queries/
- https://theeventscalendar.com/knowledgebase/wordpress-post-meta-data/ (probably what you’re looking for except it’s a bit outdated–but it’s still helpful)
and let me know if you have any follow-up questions.
February 9, 2017 at 7:34 pm #1232610Joshua
ParticipantThanks for this. What was tripping me up was that _EventStartDate is just a string so I had to convert it into a datetime object to work with it like so:
<?php
$start = get_post_meta( get_the_ID(), '_EventStartDate', true );date_default_timezone_set('America/Chicago');
$date = date("M n", strtotime($start));
echo '‘ . $date . ‘‘;
?>Joshua Michaels
studio.bio
web development | UI/UX design | wordpress | design | branding | e-commerce | interactiveFebruary 10, 2017 at 3:09 pm #1233113Cliff
MemberIt depends where and when you’re trying to use this, but you may be interested in using event_start_timestamp() from /wp-content/plugins/the-events-calendar/src/Tribe/Timezones.php
Or tribe_format_date(), which uses date_i18n().
Anyway, let me know if I can be of further help.
March 4, 2017 at 8:35 am #1249470Support 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 -
AuthorPosts
- The topic ‘Event custom meta fields for WP_Query’ is closed to new replies.
