# Show Event Dates in Search Results

> Adds the event's date (and venue when there is one) in front of its excerpt in search results, so visitors can tell upcoming events from old ones before clicking.

- Type: PHP
- Runs: Frontend only
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: events-calendar, search, dates
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/tec-search-results-event-date/

## Code

```php
add_filter( 'get_the_excerpt', function ( $excerpt, $post ) {
    if ( ! is_search() || ! $post || 'tribe_events' !== $post->post_type || ! function_exists( 'tribe_get_start_date' ) ) {
        return $excerpt;
    }

    $venue = function_exists( 'tribe_get_venue' ) ? tribe_get_venue( $post->ID ) : '';
    $meta  = tribe_get_start_date( $post, false ) . ( $venue ? ' · ' . $venue : '' );

    return '[' . wp_strip_all_tags( $meta ) . '] ' . $excerpt;
}, 20, 2 );
```

## Notes

Only affects events; other results keep their usual excerpt.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Event Dates in Search Results" 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/
