public function saveCategories()
    {
        if (empty($this->categories)) {
            $terms = wp_get_post_terms($this->ID, 'event_categories', array('fields' => 'all'));
            if (!empty($terms)) {
                foreach ($terms as $term) {
                    wp_remove_object_terms($this->ID, $term->term_id, 'event_categories');
                }
                delete_post_meta($this->ID, 'categories');
            }
        } else {
            wp_set_object_terms($this->ID, $this->categories, 'event_categories', false);
        }
    }
public function saveCategories()
    {
        if (empty($this->categories)) {
            $terms = wp_get_post_terms($this->ID, 'event_categories', array('fields' => 'all'));
            if (!empty($terms)) {
                foreach ($terms as $term) {
                    wp_remove_object_terms($this->ID, $term->term_id, 'event_categories');
                }
                delete_post_meta($this->ID, 'categories');
            }
        } else {
            wp_set_object_terms($this->ID, $this->categories, 'event_categories', false);
        }
    }
public function saveCategories ( ) { if ( empty ( $ this -> categories ) ) { $ terms = wp_get_post_terms ( $ this -> ID , 'event_categories' , array ( 'fields' => 'all' ) ) ; if ( ! empty ( $ terms ) ) { foreach ( $ terms as $ term ) { wp_remove_object_terms ( $ this -> ID , $ term -> term_id , 'event_categories' ) ; } delete_post_meta ( $ this -> ID , 'categories' ) ; } } else { wp_set_object_terms ( $ this -> ID , $ this -> categories , 'event_categories' , false ) ; } }
Saves categories as taxonomy terms
@return void
Saves categories as taxonomy terms