Created
December 27, 2017 14:21
-
-
Save vicskf/47709449ff2a8b74c079a46a2931ede4 to your computer and use it in GitHub Desktop.
TEC Event Aggregator > Assign a category based on event title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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