-
AuthorPosts
-
October 1, 2020 at 1:52 am #1249754
Hi, I’m using the Blog Posts element to display my Events Calendar events, because I need to be able to query in a custom taxonomy (the Upcoming Events element only lets me query by category). But the Blog Post element doesn’t show the event time in the blog meta — see bottom of http://12x.f4e.mwp.accessdomain.com/property/camino-del-mar — do you know how I might get those event times to show next to the date? Thanks and lmk if you have any questions.
October 6, 2020 at 8:47 am #1250757Hey sky19er,
Thank you for the inquiry.
The event time is not included in the blog post template by default, so it has to be added manually by editing the shortcode file or the post template. You could start by editing the includes > loop-index.php file around line 233 where the blog meta container starts.
You may also need to use the following function to get the event date.
// https://docs.theeventscalendar.com/reference/functions/tribe_get_start_date/
Best regards,
IsmaelOctober 7, 2020 at 8:11 am #1251046Hey, thanks, Ismael, but I’m afraid this might be over my head. I’m looking at that includes > loop-index.php, around 233, and wondering: how is the tribe event date (as opposed to the post publish date) being called there? You know what I mean? The tribe event date is showing in these posts (at the bottom of https://gobeyondhomes.org/property/camino-del-mar/ for example) — so is that tribe meta somehow being displayed via that blog meta output in line 235 of the loop index?
Also, if I try to just copy/paste that function from the tribe site into either the loop index or my child theme functions file, I get a critical error. But it seems to me that event time should somehow already be available in Enfold, since it displays in that Upcoming Events element — know what I mean? Shouldn’t I be able to sort of repurpose the code that generates the tribe event date and time for the Upcoming Events element and use it in the Blog Element?
Sorry, I know it’s probably my lack of proficiency in php that’s preventing me from understanding, but if you can offer any other clues, I sure would appreciate it.
October 9, 2020 at 11:49 am #1251670Hi,
Thank you for the update.
The event posts also have a published date which is what the blog template displays by default. The Blog Posts element is not really intended to display events but it can be modified if necessary.
Please edit the includes > loop-index.php file and look for this code around line 377:
echo "<time class='date-container minor-meta updated' >" . get_the_time( get_option( 'date_format' ) ) . '</time>';
Replace it with:
$time = get_the_time( get_option( 'date_format' ) ); if(get_post_type(get_the_ID() == 'tribe_event')) { $time = tribe_get_start_date(get_the_ID(), true); } echo "<time class='date-container minor-meta updated' >" . $time . '</time>';
This will display the event time instead of the published date if the post type is event.
Best regards,
IsmaelOctober 10, 2020 at 7:25 am #1251807Epic, man — you killed it — thank you!!! Now, is there any way for me to get that in my child theme?
October 11, 2020 at 3:24 am #1251983Hi,
You can place the edited file within the child theme structure.
Best regards,
Jordan ShannonOctober 11, 2020 at 7:08 am #1251997Oh, thanks, sorry — I had tried that, but it seemed like it wasn’t working — but I just tried again and it does seem to be working now, so I guess I just did something wrong the first time. OK, great, thanks!!! Feel free to close this thread.
October 12, 2020 at 5:02 am #1252160 -
AuthorPosts
- The topic ‘show event time in blog meta’ is closed to new replies.