Signature
apply_filters( 'mam_geodirectory_event_card', array $card, int $post_id );
| Parameter | Type | Description |
|---|---|---|
$card |
array | An event card definition with title, image, date, and other display fields. |
$post_id |
int | The post ID of the event being rendered. |
Returns: array — the modified card. You must return it.
Purpose
Lets you mutate a single event card before it is appended to a listing’s events content section. The plugin renders one card per linked event (or one per scheduled date for recurring events). This filter fires once per card.
Use cases:
- Add a custom badge (e.g., “Members only”) based on event meta.
- Override the card’s image with a richer asset.
- Append a custom subtitle line.
When it runs
In mam_gd_content_blocks::mam_content_section_events (and a sibling at line 447 for the events-section path), once per event card:
$options['cards'][] = apply_filters( 'mam_geodirectory_event_card', $card, $post->ID );
For non-event listings, this fires for each linked event found in the cross-post-links table. For event listings (when displayed inside another event’s “linked events” section), the same filter fires.
Card shape
The plugin builds cards roughly like:
$card = [
'id' => $event_id,
'title' => 'Live Music Friday',
'image' => 'https://.../event.jpg',
'date' => 'Aug 12, 2026',
'date_label' => 'Aug 12 - 9:00am to 5:00pm',
'venue' => 'Joe's Coffee',
'venue_id' => 42,
'url' => 'https://example.com/event/live-music-friday',
];
(Exact shape depends on whether the event is recurring; see Mobile listing data shape — event-only extensions.)
Example
add_filter( 'mam_geodirectory_event_card', 'my_app_add_members_only_badge', 10, 2 );
function my_app_add_members_only_badge( $card, $post_id ) {
$is_members_only = (bool) get_post_meta( $post_id, 'members_only', true );
if ( $is_members_only ) {
$card['badge'] = 'Members only';
}
return $card;
}
Gotchas
- Frozen field names. Renaming or unsetting
id,title, orimagewill break the app’s event card rendering. Add new keys; do not remove existing ones. - Runs on every render. A listing with 50 linked events will fire this filter 50 times. Avoid per-card DB queries; cache per-request if needed.
- Always return the card. Returning
nullorvoidproduces broken cards. - Card shape is not guaranteed. A recurring event has slightly different keys than a single-occurrence event. Use
??defaults orisset()checks on keys you depend on.
Verification
This article was last verified against:
- Plugin:
mam-geodirectoryv2.1.5 - Source:
includes/mam_gd_content_blocks.php(lines 252 and 447)
Re-verify whenever the card-build logic changes shape, the event-section filter signature changes, or the recurring-event branch is restructured.
Related articles
- Plugin: mam-geodirectory
- Listing detail content sections
- Mobile listing data shape
- Hook: mam_gd_date_format
Metadata
| Field | Value |
|---|---|
| Article type | Hook Reference |
| Plugin slug | mam-geodirectory |
| Applies to plugin version | 2.1.5+ |
| Category | Extending MAM Suite |
| Hook type | filter |
| Audience | PHP developer |
| Last verified | 2026-05-01 |
