Support

Home Forums Event Espresso Premium Setting the Event Category on the Event

Setting the Event Category on the Event

Posted: August 29, 2016 at 7:45 pm

Viewing 2 reply threads


Chris

August 29, 2016 at 7:45 pm

I need to set the category on a set of generated events.

I have already created the event instance and added the needed relations. However, I’m having difficulty setting the category on the event.

I’ve attempted to use a few different methods.

$event->add_event_category("Campus Tour", $taxonomy_term->ID());

$taxon_relationship->_add_relation_to($event, "Event");
$taxonomy_term->_add_relation_to($taxonomy, "Term");

Can you shed some light on how to set the category?


Josh

  • Support Staff

August 30, 2016 at 4:38 am

You can set the category with
wp_set_object_terms().

There are a few places where Event Espresso 4 uses the same function to set event categories on events:

https://github.com/eventespresso/event-espresso-core/blob/master/caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php#L576

https://github.com/eventespresso/event-espresso-core/blob/master/core/CPTs/EE_Register_CPTs.core.php#L551

https://github.com/eventespresso/event-espresso-core/blob/master/tests/testcases/core/db_models/EEM_Term_Relationship_Caps_Test.php#L47


Chris

August 30, 2016 at 8:55 am

Got it, thank you!

Viewing 2 reply threads

The support post ‘Setting the Event Category on the Event’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso