Support

Home Forums Event Espresso Premium Date/Time Range in Upcoming Event Widget

Date/Time Range in Upcoming Event Widget

Posted: July 8, 2015 at 9:46 am

Viewing 12 reply threads


Kirstin

July 8, 2015 at 9:46 am

Hello –

I would like the date and time range to display as:
Date1 – Date2
Time1 – Time2

in the Upcoming Event Widget instead of how it is currently displaying:
Date1 Time1 – Date 2 Time2

Could you please advise how to do this?

Thank you.


Lorenzo Orlando Caum

  • Support Staff

July 8, 2015 at 10:18 am

Hi Kirstin, this will require some custom coding and we can provide you with some information on getting started.

The first thing that you’ll need to do is create a custom widget to handle these edits. Please take a look at these steps:

https://eventespresso.com/topic/attempting-to-customize-upcoming-events-widget-no-widget-php-available/#post-102681

Then if you are comfortable making those changes, then please go ahead and do so and reply here so we can share additional information on adjusting the date time display.


Lorenzo


Kirstin

July 8, 2015 at 11:18 am

Lorenzo,

I have the widget created and have edited the .php as instructed. I am uncertain how to register and load the widget. Where does this code go?

// Register and load the widget
function my_load_customEE_widget() {
register_widget( ‘the_custom_EEW_Upcoming_Events’ );
}
add_action( ‘widgets_init’, ‘my_load_customEE_widget’ );

Thank you,
Kirstin


Lorenzo Orlando Caum

  • Support Staff

July 8, 2015 at 11:25 am

Hi, that would go into your into your child theme’s functions.php file or via a site specific plugin.


Lorenzo


Kirstin

July 8, 2015 at 11:44 am

Lorenzo –

I added the code to a site specific plugin. I received the following error:

Fatal error: Class ‘the_custom_EEW_Upcoming_Events’ not found in /home/content/p3pnexwpnas04_data02/48/2385748/html/wp-includes/widgets.php on line 560

Thank you.


Dean

July 9, 2015 at 7:23 am

Did you add the Class code as well? The error states the Class is missing.

class the_custom_EEW_Upcoming_Events  extends WP_Widget {
 
    /**
     * Register widget with WordPress.
     */
    function __construct() {
        parent::__construct(
            'custom-ee-upcoming-events-widget',
            __( 'Custom Event Espresso Upcoming Events', 'event_espresso' ),
             array( 'description' => __( 'A custom widget to display your upcoming events.', 'event_espresso' )),
            array(
                'width' => 300, 
                'height' => 350, 
                'id_base' => 'ee-upcoming-events-widget'
            )
        );
    }


Kirstin

July 9, 2015 at 8:33 am

Okay, the plugin is created and registered. Please let me know next steps to alter the date and time. Thank you.


Kirstin

July 10, 2015 at 2:57 pm

I appreciate any help you can provide in completing this widget to change the way the date/time is displayed in my custom widget. Thank you


Josh

  • Support Staff

July 10, 2015 at 3:34 pm

I can advise a different approach than what Lorenzo earlier suggested when he said to create a new widget. Creating a new widget is unnecessary if all you’re doing is changing the format of how the date and time ranges are displayed. This is because the espresso_event_date_range() function is pluggable and can load from your custom plugin (tip: make sure your plugin loads before Event Espresso does by naming it starting with the letters a-eu).

To make your own custom date range function, you go in and copy the espresso_event_date_range() function from Event Espresso’s /public/template_tags.php file, into your own plugin.

Then, you change the last few lines of that function just like the way it’s changed in this example:

https://gist.github.com/joshfeck/143e808c38d9ac82a658


Kirstin

July 10, 2015 at 4:27 pm

Do I have to copy the complete contents of the templates_tags.php file into the custom plugin or can I simple add the revised function?


Kirstin

July 10, 2015 at 4:35 pm

I got it working. Thanks so much! Awesome and quick support, as always!


Dean

July 13, 2015 at 4:15 am

Hi Kirstin,

Glad you got it working!

I’ll mark this as resolved, if you have further queries on this topic please open a new thread and link to this one.


Josh

  • Support Staff

July 13, 2015 at 10:55 am

Hi Kirsten,

You only copy the one function that you customize, you do not copy the entire file.

Viewing 12 reply threads

The support post ‘Date/Time Range in Upcoming Event Widget’ 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