With the new Block 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 ) {
$template_search = array_column( $template, 0 );
$organizer = array_search( 'tribe/event-organizer', $template_search );
unset( $template[ $organizer ] );
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.