Skip to content

Instantly share code, notes, and snippets.

@skyshab
Created May 29, 2019 15:13
Show Gist options
  • Save skyshab/0e4ea8a1955dcd6e9ca2703aa9b1ef7f to your computer and use it in GitHub Desktop.
Save skyshab/0e4ea8a1955dcd6e9ca2703aa9b1ef7f to your computer and use it in GitHub Desktop.
Custom Block editor template for event with tickets
<?php
// Return a custom order of the default blocks on an event.
// to change the order of the blocks, arrange the lines the blocks are added to the array.
// To remove a block from being added by default, comment out the line for the block.
add_filter( 'tribe_events_editor_default_template', function( $template ){
// initiate our array
$template = array();
// default blocks
$template[] = array( 'tribe/event-datetime' );
$template[] = array(
'core/paragraph',
array(
'placeholder' => __( 'Add Description...', 'the-events-calendar' ),
),
);
$template[] = array( 'tribe/event-price' );
$template[] = array( 'tribe/event-organizer' );
$template[] = array( 'tribe/event-venue' );
$template[] = array( 'tribe/event-website' );
$template[] = array( 'tribe/event-links' );
// tickets blocks
$template[] = array( 'tribe/tickets' );
$template[] = array( 'tribe/rsvp' );
$template[] = array( 'tribe/attendees' );
// return the array of blocks with our custom order.
return $template;
}, 500);
// Prevent tickets from being added again by the plugin. We've already added them in the order we want.
remove_action( 'admin_init', array( tribe( 'tickets.editor' ), 'add_tickets_block_in_editor' ) );
@jminexa
Copy link

jminexa commented Dec 6, 2021

Hi,

This is more or less what i'm looking for, only I can't figure out where I should put this php file.
Can you guide me into the right direction?

functions.php?

@IntrepidRealist
Copy link

IntrepidRealist commented Oct 25, 2022

@jminexa You can put this code in your child theme's functions.php.

It works like a charm for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment