Support

Home Forums Event Espresso Premium How to display multi day events date range in upcoming widget in EE4

How to display multi day events date range in upcoming widget in EE4

Posted: April 4, 2014 at 1:42 pm

Viewing 3 reply threads


Stewart goodwin

April 4, 2014 at 1:42 pm

How can we modify the upcoming events widget to display a date range (e.g. April 4-5, 2014) instead of what it displays by default?


Dean

April 7, 2014 at 1:06 am

Hi Stewart,

The only way to do this is to modify the actual widget.

You can do this by copying event-espresso/templates/widget.php over to wp-content/uploads/espresso/templates.

There you can edit the PHP to include the event date. I would do something liek this:

line 130

<li><a href="<?php echo $registration_url; ?>"><?php echo stripslashes_deep($event->event_name) ?> - <span class="widget-event-date"><?php echo event_date_display($event->start_date) ?></span></a>

Change to

<li><a href="<?php echo $registration_url; ?>"><?php echo stripslashes_deep($event->event_name) ?> - <span class="widget-event-date"><?php echo date( 'd', strtotime( $event->start_date) ) . ' - ' . date('d M Y', strtotime( $event->end_date ) ) ?></span></a>


Stewart goodwin

April 11, 2014 at 8:32 pm

Thank you. I don’t seem to have a widget.php file in my file structure. I have a EEW_Upcoming_Events.widget.php but has different code:

<code>if ( $show_dates ) {
								echo  &#039;&lt;h6 class=&quot;ee-calendar_year-icon-small&quot;&gt;&#039; . __(&#039;Event Dates: &#039;, &#039;event_espresso&#039;) . &#039;&lt;/h6&gt;&#039;;
								echo espresso_list_of_event_dates( $event-&gt;ID(), &#039;D M jS, Y&#039;, &#039;@ g:i a&#039;, FALSE );
							}</code>

Any thoughts? I am using EE4.


Dean

April 14, 2014 at 5:52 am

Hi Stuart,

My apologies, I just didn’t see EE4 in the question title, so yes the code will be very different.

You are sort of in the right place with the EEW_Upcoming_Events.widget.php file. It is certainly the one that outputs the dates.

To make the changes you need though, it would require modifying a function called espresso_list_of_event_dates, which is found in the core/helpers/EEH_Event_View.helper.php file.

This is a pluggable file so can be copied to a custom plugin or to your theme’s functions.php.

Modifying this requires more assistance than we can provide in support, it really needs a developer to look at it. I spent some time examining it and to get it to do what you want will require an hour or more, or someone more skilled than I!

Viewing 3 reply threads

The support post ‘How to display multi day events date range in upcoming widget in EE4’ 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