Using The Events Calendar Plugin with Timber and Twig
Ensure the Timber Plugin or Composer dependency is installed
Install the Events Calendar Plugin
This works for the free version. If using the paid version of the plugin – you might have to modify the other steps.
Activate the Events Calendar Plugin
Create the template file for the override
Create a file at the following location inside the Timber theme tribe/events/v2/default-template.php
Add the code to the template file
See code snippet 1 below
Render the markup in twig
See code snippet 2
Code Snippet 1
default-template.php
<?php
/**
* Default Events Template
*
* @package TribeEventsCalendar
* @version 4.6.23
*
*/
use Tribe\Events\Views\V2\Template_Bootstrap;
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
$context = Timber::get_context();
$context['tribe_markup'] = tribe( Template_Bootstrap::class )->get_view_html();
Timber::render( array( 'events.twig' ), $context );
Code Snippet 2
<div class="events-container">
{{tribe_markup}}
</div>
More related information can be found here https://github.com/timber/timber/issues/312#issue-39623334