php - Query to add taxonomies terms in WordPress -


i using json api plugin wordpress , able add info meta boxes (custom fields) custom post type cannot same taxonomies.

the code meta boxes (custom fields) below:

// prettier urls, map of post_type => (url_param_name => meta_field_name)  $custom_post_meta_fields = array( 'classifieds' => array( 'price' => 'wpcf-price-with-discount', 'condition' => 'wpcf-condition' ) );  // handle metadata global $custom_post_meta_fields; if ($this->id && !empty($custom_post_meta_fields[$wp_values['post_type']])) {   foreach ($custom_post_meta_fields[$wp_values['post_type']] $param => $meta) {     update_post_meta($this->id, $meta, $values[$param]);   } } 

can suggest similar code adding taxonomies terms please? example post type 'classifieds' has got taxonomy 'type' , want add terms it.

also additional idea somehow amend second part of code after //handle metadata

 function set_custom_taxonomies($type) { global $json_api; $taxonomies = get_taxonomies(array(   'object_type' => array($type),   'public'   => true,   '_builtin' => false ), 'objects'); foreach ($taxonomies $taxonomy_id => $taxonomy) {   $taxonomy_key = "taxonomy_$taxonomy_id";   if (!$json_api->include_value($taxonomy_key)) {     continue;   }   $taxonomy_class = $taxonomy->hierarchical ? 'json_api_category' : 'json_api_tag';   $terms = get_the_terms($this->id, $taxonomy_id);   $this->$taxonomy_key = array();   if (!empty($terms)) {     $taxonomy_terms = array();     foreach ($terms $term) {       $taxonomy_terms[] = new $taxonomy_class($term);     }     $this->$taxonomy_key = $taxonomy_terms;   } }  } 

thank in advance!


Comments