Just giving this a bit of a bump since I’m still trying to find a solution
I don’t see a function for adding tags.
Here’s some code to import events from a csv file (in the function importEventsCSV): https://github.com/webaware/events-manager-import-export/blob/master/includes/class.EM_ImpExpImport.php
The code is pretty old so it doesn’t have code to handle tags but it does handle categories. I think tags can be handled is a way similar to categories. Just use EM_Tag instead of EM_Category. When calling wp_insert_term use ‘event-tags’ instead of ‘event-categories’.
Also you wouldn’t call $eventcats = $event->get_categories();.
I see the following code in events-manager/classes/em-event.php:
//general taxonomies including event tags
$terms = get_the_terms( $this->post_id, $tax_data['name']);
$term_slugs = array();
if( is_array($terms) ){
foreach($terms as $term){
if( !empty($term->slug) ) $term_slugs[] = $term->slug; //save of category will soft-fail if slug is empty
}
}
foreach($post_ids as $post_id){
wp_set_object_terms($post_id, $term_slugs, $tax_data['name']);
}
-
This reply was modified 3 years ago by
joneiseman.
Hey @joneiseman
Cheers for the reply! Still trying to figure things out, but I have been looking through what you’ve sent me as well. The main issue is that I’m trying to make the process as simple as possible for the people running the backend of this site as they are not developers themselves, and the more steps I add in, the more likely it is that something may get stuffed up. I do see what your getting at though, there doesn’t appear to be a system for adding tags through code directly, but you can add them through events, so I maybe have an idea but I’ll need to see how it goes.
My idea is maybe make a dummy event that I can use to add tags through, and then once the tag has been added using it, delete the dummy event. I don’t know if it’ll work but maybe thats a workaround for now.
Cheers for the advice though!