With the Block (Gutenberg) Editor, all post types that have support for default templates for which order your block will show up when you create a new post. For events, we introduced a filter to allow you to easily customize your default content.

  • Hook name: tribe_events_editor_default_template
  • Parameters used on this Filter
    • $template – Array with Template blocks to be generated
    • $post_type – String with the Post type we are dealing with, defaults to tribe_events.
    • $args – Array of arguments used to set up the Templates

We have a list of default blocks we use inside of The Events Calendar. In the following order:

  • tribe/event-datetime
  • core/paragraph
  • tribe/event-price
  • tribe/event-organizer
  • tribe/event-venue
  • tribe/event-website
  • tribe/event-links

Here a few examples of how you would use this to, for example, remove the organizer block or change the whole template.

Remove the Organizer block

<?php
add_filter( 'tribe_events_editor_default_template', function( $template ) {
	// collect an array of template values, like "tribe/event-price" and tribe/event-venue"
	$template_search = array_column( $template, 0 );

	// Get the index of the "tribe/event-price"
	$price = array_search( "tribe/event-price", $template_search );

	// @link: https://www.php.net/manual/en/function.array-splice.php
	array_splice(
		// The original $template array
		$template,
		// The integer value of the price index (such as 2)
		$price,
		// How many items we want to remove from $template (just 1: the price)
		1
	);

	// Return the price-spliced $template
	return $template;
}, 11, 1 );

Change the template

<?php
add_filter( 'tribe_events_editor_default_template', function( $template ) {
  $template = [
    [ 'tribe/event-datetime' ],
    [ 'core/paragraph', [
      'placeholder' => __( 'Add Description...', 'the-events-calendar' ),
    ], ],
    [ 'tribe/event-organizer' ],
    [ 'tribe/event-venue' ],
  ];
  return $template;
}, 11, 1 );

It’s important to remember that the default value for each one of the blocks is an array that has the first key (0) as the block slug.

Adding more WordPress core blocks when changing the template

Note that the previous PHP snippet includes the default paragraph block from WordPress, so you can see that you can also include other WordPress default blocks if you need.

As an example, if you need to include the Featured Image block, you’ll need to include the ['core/post-featured-image'] on the position you want to appear.

Let’s see how you can add it before the paragraph block:

<?php
add_filter( 'tribe_events_editor_default_template', function( $template ) {
  $template = [
    [ 'tribe/event-datetime' ],
    [ 'core/post-featured-image' ],
    [ 'core/paragraph', [
      'placeholder' => __( 'Add Description...', 'the-events-calendar' ),
    ], ],
    [ 'tribe/event-organizer' ],
    [ 'tribe/event-venue' ],
  ];
  return $template;
}, 11, 1 );

You can find a list of all default WordPress blocks at https://developer.wordpress.org/block-editor/reference-guides/core-blocks/ and use their “Name” to include them on that list.