Add event content to an event widget

One customization request we've seen come up regularly is how to add post content to the Mini Calendar and the Events List widgets. Here we'll take a look at how to do just that.

The Scenario

Let's say we have placed the Mini Calendar widget in the sidebar of a page. We can expect to see a lot of information about our events, including the dates, times, location, and more, depending on our widget settings.

That's nice and dandy, but what if we want to include a little more information about our events? Specifically, let's find a way to add the event's excerpt below the dates.

kb-widgets-add-excerpt

How it's Done

The key here is that we can use the default WordPress function for the_excerpt() to display content from the event directly in the widget.

This will require a template override. If you're new to overriding calendar templates, then it's a good idea to check out our Themer's Guide, which will walk you through the process step-by-step. The basic idea is that we will be creating a copy of one of the plugin's templates, then adding it to our theme files. This allows us to override the template without touching the core code of the plugin.

  • Make a copy of the Mini Calendar's list.php file. This is located in /plugins/events-calendar-pro/src/views/pro/widgets/mini-calendar/list.php.
  • Make a new folder in your theme directory. Call it tribe-events.
  • Make a new folder in that one. Call it pro.
  • Make a new folder in that one. Call it widgets.
  • Make one last new folder in that one. Call it mini-calendar.
  • Add the file. Drop the copied list.php file in that last folder.

Presto! Now that the template is in our theme directory, we can modify to suit our needs. In this case, we will add this:

[php]
<?php the_excerpt(); ?>
[/php]

...right below the single event module. As of this writing, that is after Line 24 of the template.

KB widget excerpts

Now, we can save our work, head back to our widget and see the event's excerpt display with the rest of event's information. Nice work!

That's great, but how about the List Widget?

The above example is indeed applicable to only the Mini Calendar. However, the same technique applies to the Events List widget in both The Events Calendar and The Events Calendar PRO.

For the Events List widget in The Events Calendar:

  • Make a copy of the list-widget.php file. This is located in /plugins/the-events-calendar/src/views/widgets/list-widget.php.
  • Make a new folder in your theme directory. Call it tribe-events.
  • Make a new folder in that one. Call it widgets.
  • Add the file. Drop the copied list-widget.php file in that last folder.

For the Advanced Events List widget in Events Calendar PRO:

  • Make a copy of the list-widget.php file. This is located in /plugins/events-calendar-pro/src/views/pro/widgets/list-widget.php.
  • Make a new folder in your theme directory. Call it tribe-events.
  • Make a new folder in that one. Call it pro.
  • Make a new folder in that one. Call it widgets.
  • Add the file. Drop the copied list-widget.php file in that last folder.

Now we can add the same the_excerpt() snippet wherever we would like it to display.