Blocks & Templates
Eventonomy blocks use the WordPress Interactivity API. They share a single eventonomy store and a canonical REST envelope. Templates are overridable from your theme.
What You Will Learn
- The shared Interactivity store and its stable surface
- How to register a custom block that inherits store hydration
- How to override templates from a child theme
- The shortcode surface for classic-editor parity
- The
evnm_blocksfilter
The Shared Interactivity Store
All blocks share one store namespaced eventonomy. Calling store('eventonomy', …) from a second script merges into it - it does not replace it.
Stable public surface:
| Member | Type | Description |
|---|---|---|
state.config |
object | The app-config payload from GET /settings/app-config |
state.currentEvent |
object|null | The event loaded on the current single-event page |
state.isBusy |
bool | True while an async action is in flight |
actions.rsvp(e) |
generator action | Submit/update an RSVP |
actions.buyTicket(e) |
generator action | Initiate checkout (Pro) |
actions.refresh(e) |
generator action | Reload the current event from the API |
callbacks.onEventLoaded() |
callback | Fires when state.currentEvent is populated |
Extending the store:
import { store, getContext } from '@wordpress/interactivity';
import apiFetch from '@wordpress/api-fetch';
store( 'eventonomy', {
state: {
get myCustomValue() { return getContext().event?.my_field ?? ''; }
},
actions: {
*loadMyData() {
const ctx = getContext();
ctx.busy = true;
try {
const res = yield apiFetch( { path: `/my-addon/v1/events/${ ctx.event.id }/my-data` } );
ctx.myData = res.items;
} finally { ctx.busy = false; }
},
},
} );
Always use wp.apiFetch (nonce applied from app config) - never raw fetch().
Registering a Custom Block
Use the evnm_blocks filter to register a third-party block that inherits shared store hydration and evnm_get_view_data() access:
add_filter( 'evnm_blocks', function ( $blocks ) {
$blocks['my-addon/event-video'] = [
'path' => __DIR__ . '/build/event-video',
'uses_store' => true,
'view_data' => [ 'event' ],
];
return $blocks;
} );
In your block's render.php, read view data and wire Interactivity API attributes:
$event = evnm_get_view_data( 'event', $attributes['eventId'] ?? 0 );
?>
<div
data-wp-interactive="eventonomy"
data-wp-context='<?php echo wp_json_encode( [ 'event' => $event ] ); ?>'
>
<span data-wp-text="state.myCustomValue"></span>
<button data-wp-on--click="actions.loadMyData">Load</button>
</div>
Template Overrides
Override any bundled template by copying it into your theme (or child theme) under an eventonomy/ subdirectory.
Override order: {child-theme}/eventonomy/{tpl}.php → {parent-theme}/eventonomy/{tpl}.php → bundled templates/{tpl}.php.
Available templates:
| File | What it renders |
|---|---|
single-event.php |
Single event page shell |
events-list.php |
Events archive list |
event-card.php |
One card in Grid/List view |
rsvp-form.php |
RSVP form |
parts/event-meta.php |
Date, venue, organizer meta row |
parts/event-date.php |
Date/time formatted output |
parts/organizer.php |
Organizer name/link |
Rules for safe overrides:
- Templates receive a documented read-only
$view_dataarray prepared by Services. - Zero DB calls inside templates - add data upstream via
evnm_rest_prepare_eventor view-data filters, never by querying in the template. - Use
evnm_template_part(filter) to swap a file path programmatically, andevnm_template_part_argsto pass extra data.
Emails as Overridable Templates
Email templates also follow the override order. Copy templates/emails/{key}.php into {child-theme}/eventonomy/emails/{key}.php to customize the HTML for a specific email.
Pro - The custom email template builder in wp-admin (Pro) is an alternative to file-based overrides.
Shortcodes
Each block has a shortcode equivalent for classic-editor and page-builder use. Shortcodes call render_block() internally, so the output is byte-for-byte identical to placing the block.
| Shortcode | Block |
|---|---|
[eventonomy_calendar view="month"] |
eventonomy/calendar |
[eventonomy_events per_page="6" view="list" category="music"] |
eventonomy/events-list |
[eventonomy_upcoming count="3"] |
eventonomy/upcoming |
[eventonomy_event id="42"] |
eventonomy/single-event |
[eventonomy_my_events] |
eventonomy/my-events |
[eventonomy_search] |
eventonomy/search-filter |
[eventonomy_submit event_id="0" redirect_url="/events/"] |
eventonomy/event-editor |
What's Next?
Drive and test Eventonomy from the command line.