Support

Home Forums Event Espresso Premium ACF after event title

ACF after event title

Posted: February 11, 2016 at 4:06 am


William Tozzo

February 11, 2016 at 4:06 am

What is the function to show the advanced custom field meta box below the event title for ‘author_name’?
Is it best to add the function in the templates, or do you have a hook or filter function that I can use?
I have the field working in the event editor, but I can’t see how to show it on the front end.
Thanks.


Tony

  • Support Staff

February 11, 2016 at 7:10 am

Hi William,

You’ll likely need to add this to the theme template file. Event Espresso uses your sites theme to output the event details, so a hook would need to be within your theme rather than EE.

Would the author_name you are setting within ACF be different from the user set as the event author of the event?

Does your theme include the option to display post meta (which usually include the event author)?


William Tozzo

February 11, 2016 at 7:55 am

Thanks Tony,

The author name would be different to the post meta, think author e.g. Stephen King. We can relabel the ACF meta box to ‘play_author’ to avoid confusion.

What would the hook be for the event list page?
Would it be before the header </div> here?

<?php do_action( 'AHEE_play_author_after_espresso_events-header'); ?>

Also, how can we show the date range of multiple dates for each event please?

Thanks.


Tony

  • Support Staff

February 11, 2016 at 10:41 am

The author name would be different to the post meta, think author e.g. Stephen King. We can relabel the ACF meta box to ‘play_author’ to avoid confusion.

Ahh, ok. I understand.

What would the hook be for the event list page?
Would it be before the header here?

There’s lots of hooks available within Event Espresso, but none that will allow you to output the event meta directly below the_title as its controlled by your theme. EE hooks into the_content and adds the details it needs to, the rest of the output is from your theme (including the title) so for that you’ll need to create a custom template and either add a hook you can use yourself or call the meta value directly from within the template.

<?php do_action( 'AHEE_play_author_after_espresso_events-header'); ?>

Is this a hook you have found or are you asking if this is how you would use the hook? That is not a hook from within Event Espresso so I’m not sure where it is from, sorry.

Can you link me one of the pages you want to add this to?


William Tozzo

February 11, 2016 at 2:45 pm

Thanks Tony,

I’ve managed to solve it, with your direction to focus on the theme.

To appear in the event list –
Added this

<div class="play_author"><h4><?php the_field('play_author'); ?></h4></div>

in the ‘content-espresso_events_header.php’

and the same again in the theme single.php to show in the event details.

How can we show the date range of multiple dates for each event please on the event list?
Example – June 18th, 2016 – June 20th, 2016

Is it here?

//d( $datetimes );
if ( is_array( $datetimes ) && ! empty( $datetimes )) {
global $post;
$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul">' : '';
foreach ( $datetimes as $datetime ) {
if ( $datetime instanceof EE_Datetime ) {
$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID() . '" class="ee-event-datetimes-li">';
$datetime_name = $datetime->name();
$html .= ! empty( $datetime_name ) ? '' . $datetime_name . '' : '';
$html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : '';
$html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $date_format ) . '<br/>';
$html .= '<span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $time_format );
$datetime_description = $datetime->description();
$html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : '';
$html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
$html .= '';


Lorenzo Orlando Caum

  • Support Staff

February 11, 2016 at 3:03 pm

Hi, are you referring to this function?

espresso_event_date_range()

https://eventespresso.com/wiki/ee4-themes-templates/


Lorenzo


William Tozzo

February 12, 2016 at 4:29 am

Thanks Lorenzo,

This simple function has now worked –

function espresso_list_of_event_dates() {
return espresso_event_date_range();
}

However, the end time is appearing on events that have a range of dates. I already have this function in place to remove the end times, what needs to be changed so the events with a range of end dates are also removed please?

// Remove End Time
if ( ! function_exists( 'espresso_list_of_event_dates' )) {
/**
* espresso_list_of_event_dates
* returns a unordered list of dates for an event
*
* @param int $EVT_ID
* @param string $date_format
* @param string $time_format
* @param bool $echo
* @param null $show_expired
* @param bool $format
* @param bool $add_breaks
* @param null $limit
* @return string
*/
function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
$time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
EE_Registry::instance()->load_helper( 'Event_View' );
$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
if ( ! $format ) {
return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
}
//d( $datetimes );
if ( is_array( $datetimes ) && ! empty( $datetimes )) {
global $post;
$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul">' : '';
foreach ( $datetimes as $datetime ) {
if ( $datetime instanceof EE_Datetime ) {
$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID() . '" class="ee-event-datetimes-li">';
$datetime_name = $datetime->name();
$html .= ! empty( $datetime_name ) ? '' . $datetime_name . '' : '';
$html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : '';
$html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $date_format ) . '<br/>';
$html .= '<span class="dashicons dashicons-clock"></span>' . $datetime->start_time( $time_format );
$datetime_description = $datetime->description();
$html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : '';
$html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
$html .= '';
}
}
$html .= $format ? '' : '';
} else {
$html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
}
if ( $echo ) {
echo $html;
return '';
}
return $html;
}
}


Lorenzo Orlando Caum

  • Support Staff

February 12, 2016 at 4:54 am

Hi,

You can apply a similar change to the espresso_event_date_range function.

You can find it here:

/wp-content/plugins/event-espresso-core-reg/public/template_tags.php

Move a copy of the espresso_event_date_range function into a site specific plugin and then look at the section for the time format and change time_range to start_time.


Lorenzo


William Tozzo

February 12, 2016 at 8:31 am

Thanks Lorenzo,

Any idea why just on non EE pages where we have the upcoming widget, there are now no event dates or times, but just the title of the event and image? – http://prntscr.com/a2c2wb


Lorenzo Orlando Caum

  • Support Staff

February 12, 2016 at 9:25 am

Hi,

What does it look like when you are viewing an Event Espresso page?

Have any modifications been made to the upcoming events widget (e.g. a customized version)?


Lorenzo


William Tozzo

February 12, 2016 at 10:13 am

Here’s on an events details page – http://prnt.sc/a2dl8p

No, just a bit of .css with font-colour, no php modifications specifically for the widget.


Tony

  • Support Staff

February 12, 2016 at 11:58 am

The problem is this code:

function espresso_list_of_event_dates() {
return espresso_event_date_range();
}

Your overriding a core function, with another core function but not passing any of the parameters to the function. On the single event page Event Espresso is smart enough to figure that out for you, however on a non EE page where there is no global event object there is no way for EE to know what it should be using unless you pass the event id.

We can not provide support for custom coding such as this, I recommend removing the custom function above and advise you seek help from a PHP developer that is familiar with WordPress to help you with these customizations.


William Tozzo

February 12, 2016 at 2:00 pm

Thanks Tony,

What are the correct functions to show a) no end time for any events, b) also a date range for any multiple day events, c) without affecting the upcoming widget?


Josh

  • Support Staff

February 12, 2016 at 3:08 pm

Hi Ben,

It turns out that
espresso_list_of_event_dates()
and
espresso_event_date_range()
are the correct functions. You do not modify the functions to remove the times. Instead, you pass in an empty string to the time_format parameters when you call the function, where you don’t want the times to display. So for example if you look at the core code for espresso_event_date_range(), you’ll see that it accepts the following parameters in this order:

$date_format
$time_format
$single_date_format
$single_time_format
$EVT_ID
$echo
In your template where you call the function, where you don’t want the time to display, you pass an empty string for the time format parameters, like this ' ', and times will not be displayed there.


William Tozzo

February 15, 2016 at 7:34 am

Thanks Josh, I found this post which also solved my display – https://eventespresso.com/topic/displaying-multiple-dates-as-a-range/

Thanks,
William

The support post ‘ACF after event title’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso