# Add Online and Status Details to Event Schema

> Enriches The Events Calendar's JSON-LD with eventStatus and eventAttendanceMode, marking events that have an event website but no venue as online events, as Google recommends.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: events-calendar, schema, seo
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/tec-event-schema-extras/

## Code

```php
add_filter( 'tribe_json_ld_event_object', function ( $data, $args, $post ) {
    if ( ! is_object( $data ) || ! $post ) {
        return $data;
    }

    $statuses = array(
        'cancelled'   => 'https://schema.org/EventCancelled',
        'postponed'   => 'https://schema.org/EventPostponed',
        'rescheduled' => 'https://schema.org/EventRescheduled',
    );
    $status = strtolower( (string) get_post_meta( $post->ID, 'event_status', true ) );

    $data->eventStatus = isset( $statuses[ $status ] ) ? $statuses[ $status ] : 'https://schema.org/EventScheduled';

    $has_venue = (int) get_post_meta( $post->ID, '_EventVenueID', true ) > 0;
    $url       = get_post_meta( $post->ID, '_EventURL', true );

    if ( ! $has_venue && $url ) {
        $data->eventAttendanceMode = 'https://schema.org/OnlineEventAttendanceMode';
        $data->location            = (object) array( '@type' => 'VirtualLocation', 'url' => esc_url_raw( $url ) );
    } else {
        $data->eventAttendanceMode = 'https://schema.org/OfflineEventAttendanceMode';
    }

    return $data;
}, 10, 3 );
```

## Notes

Add a custom field named event_status with the value cancelled, postponed or rescheduled to mark changed events.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Add Online and Status Details to Event Schema" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
