Skip to content

Instantly share code, notes, and snippets.

@vicskf
Created December 27, 2017 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicskf/47709449ff2a8b74c079a46a2931ede4 to your computer and use it in GitHub Desktop.
Save vicskf/47709449ff2a8b74c079a46a2931ede4 to your computer and use it in GitHub Desktop.
TEC Event Aggregator > Assign a category based on event title
<?php
/*
* When running imports with Event Aggregator it assigns a category depending on event title.
* Works upon inserting and updating events.
*/
add_filter ( 'tribe_aggregator_before_insert_event', 'tribe_aggregator_custom_event_categories' );
add_filter ( 'tribe_aggregator_before_update_event', 'tribe_aggregator_custom_event_categories' );
function tribe_aggregator_custom_event_categories ( $event ) {
$event_title = $event['post_title'];
if ( strpos( $event_title, 'golf' ) !== false ) {
$event['categories'][] = 'golftime';
}
return $event;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment