Skip to content

Instantly share code, notes, and snippets.

@benrolfe
Created December 17, 2021 15:09
Show Gist options
  • Save benrolfe/cd7c3d2396a2566938d0ea284dadcd69 to your computer and use it in GitHub Desktop.
Save benrolfe/cd7c3d2396a2566938d0ea284dadcd69 to your computer and use it in GitHub Desktop.
Display featured events
acf_register_block_type([
'name' => 'tbc_featured_events',
'title' => 'TBC Featured Events',
'render_callback' => function() {
$context = Timber::context();
$calendar = new Calendar;
$context['rows'] = get_field( 'events' );
$context['events'] = [];
foreach ( $context['rows'] as $row ) {
$context['events'][] = $calendar->getEventsByTerm( $row['search_term'] );
}
Timber::render( 'block/featured-events.twig', $context );
},
'icon' => 'calendar-alt',
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment