I'm importing Events from a Salesforce Event Manager into WordPress, specifically into the The Events Calendar. The Events Calendar creates a CPT called Events. It also has its own Categories, which have the taxonomy name of "tribe_events_cat".

Everytime a user updates an event in Salesforce they are updated in WordPress through an object-sync plugin. However, I can't set the Category through object-sync since the category is a taxonomy, not a property of the Event object.

I tried the following code but it is not working. The save_post hook is definitely firing its callback function everytime I update an Event, but the category is not being set. In this example code, I'm just trying to set any updated event to 'Retreat', which is an Event Category that I've set up.

add_action( 'save_post_tribe_events', 'fix_event_category', 1, 1);
function fix_event_category($post_id) {
    $category = array(get_cat_ID('Retreat'));
    $taxonomy = 'tribe_events_cat';
    wp_set_post_terms($post_id, $category, $taxonomy);

1 Answer 1


The answer is don't use wp_set_post_terms, use wp_set_object_terms instead. wp_set_post_terms only works with the built-in post object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.