While I have been generally happy with the plugin, I was not impressed with the lack of options that come with the events list widget.
Also, the widget only shows the title of the event and the date directly below.
But, You Can Extend the Events List Widget!
After digging through code for The Events Calendar plugin, I found that the view (controls the display) for the widget is located in /views/widgets/list-widget.php.
Here is the source code for that file — taken from the WordPress.org repo on 5-16-2014 :
<?php
/**
* Events List Widget Template
* This is the template for the output of the events list widget.
* All the items are turned on and off through the widget admin.
* There is currently no default styling, which is needed.
*
* This view contains the filters required to create an effective events list widget view.
*
* You can recreate an ENTIRELY new events list widget view by doing a template override,
* and placing a list-widget.php file in a tribe-events/widgets/ directory
* within your theme directory, which will override the /views/widgets/list-widget.php.
*
* You can use any or all filters included in this file or create your own filters in
* your functions.php. In order to modify or extend a single filter, please see our
* readme on templates hooks and filters (TO-DO)
*
* @return string
*
* @package TribeEventsCalendar
* @since 2.1
* @author Modern Tribe Inc.
*
*/
?>
<li class="tribe-events-list-widget-events <?php tribe_events_event_classes() ?>">
<?php do_action( 'tribe_events_list_widget_before_the_event_title' ); ?>
<h4 class="entry-title summary">
<a href="<?php echo tribe_get_event_link(); ?>" rel="bookmark"><?php the_title(); ?></a>
</h4>
<?php do_action( 'tribe_events_list_widget_after_the_event_title' ); ?>
<!-- Event Time -->
<?php do_action( 'tribe_events_list_widget_before_the_meta' ) ?>
<div class="duration">
<?php echo tribe_events_event_schedule_details(); ?>
</div>
<?php do_action( 'tribe_events_list_widget_before_the_meta' ) ?>
<!-- Event Title -->
</li>
First things first, always read the comments! After reading the comments in this file, I became aware that there are two ways to update the events list widget:
- Create a completely new template
- Use actions in the functions.php of a theme or in a separate plugin
For my purposes, I only wanted to add a description to each listing, so I decided to just use the actions.
But, if you need a completely new look, you could create a new template file in your theme directory at THEME_DIR/tribe-events/widgets/list-widget.php .
Adding a Description with Actions
Because all I wanted to do was add a description below the date for each event in the events list widget, my solution was pretty simple.
add_action( 'tribe_events_list_widget_after_the_meta', 'edit_tribe_widget_after_title' );
function edit_tribe_widget_after_title() {
global $post;
$event = $post;
echo wpautop( wp_trim_words( $post->post_content, 12, '… <a href=' . get_permalink( $event ) . '>Read More →</a>' ) );
}

This snippet will tie into the action that fires right after the meta in each event item, and it will insert up to 12 words of the description for each event as well as a read more link.
While I hooked into the after_meta action to add a description, you could easily use one of these other actions to modify the events list widget to your needs:
- tribe_events_list_widget_before_the_event_title
- tribe_events_list_widget_after_the_event_title
- tribe_events_list_widget_before_the_meta
- tribe_events_list_widget_before_the_meta
Because the widget calls tribe_events_event_schedule_details(), you can also use the the tribe_events_event_schedule_details filter to filter what shows up in the meta section.
Questions, Comments, Bugs?
First, there is a bug on line 44 of this plugin (bonus if you can figure out what it is). I checked the GitHub repository and they had already fixed it, it just hasn’t been pushed to the WordPress repository.
If there are any other questions or comments, please leave a comment below. If you see any other bugs than the one mentioned above, please leave a comment below so I can fix it 🙂
Leave a Reply