Skip Navigation

[Resolved] Event start date

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a View showing Event posts from the Tribe Events plugin. I would like to show the event start date field in the View, but I cannot find it in the custom field list.

Solution: You can create a custom shortcode to display the event start date:

add_shortcode('tribe-start-date', 'tribe_start_date_shortcode');
function tribe_start_date_shortcode() {
global $post;
return tribe_get_start_date( $post->ID, false, '(l dS F Y)' );
}

Relevant Documentation:
https://theeventscalendar.com/function/tribe_get_start_date/

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by digitalF 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1196848

I'm using the Tribe Events plugin and trying to get the events start date inserted into my view. The only option I can see date wise is the post date. How can I have the event start short-code displayed in my view?

Many thanks

#1196927

You can create a custom shortcode using their API. Add this code in your child theme's functions.php file, or create a new snippet in Toolset > Settings > Custom code:

add_shortcode('tribe-start-date', 'tribe_start_date_shortcode');
function tribe_start_date_shortcode() {
  global $post;
  return tribe_get_start_date( $post->ID, true );
}

Then in your View:

Event start date: [tribe-start-date]

Their API documentation is here if you want to change the output format, hide the time, or whatever:
https://theeventscalendar.com/function/tribe_get_start_date/

#1196938

Hi Cristain,

Thank you so much, that's worked a charm! One small tweak however, the date is currently displaying as: 14th February, 2019 @ 7:30 pm

The day format I was previously using was: (l dS F Y) - is there any way I can add this to the short-code?

Thanks again for your help!

#1197357

Yes, I believe the third parameter of the tribe_get_start_date function can be a string PHP format. So you can add it directly like this:

return tribe_get_start_date( $post->ID, true, '(l dS F Y)' );
#1197742

Thanks Christian, I've changed the code in the settings to:

add_shortcode('tribe-start-date', 'tribe_start_date_shortcode');
function tribe_start_date_shortcode() {
global $post;
return tribe_get_start_date( $post->ID, true, '(l dS F Y)' );
}

I'm still seeing the 'time' in the frontend next to where the date is. Do I need to modify the view short-code? So just the date is shown without the time.

Many thanks

#1198203
Screen Shot 2019-02-10 at 10.11.40 AM.png

Yes, the second parameter to tribe_get_start_date should be false instead of true. Screenshot of the corresponding documentation here for your reference.

return tribe_get_start_date( $post->ID, false, '(l dS F Y)' );
#1198610

My issue is resolved now. Thank you very much for all your help!