Update more terms with wp_set_object_terms
-
I update a custom fields using pods like the following:
add_action( 'pods_api_post_save_pod_item_release', 'my_tax_update', 10, 3 ); function my_tax_update( $pieces, $is_new_item, $id ) { $terms = $pieces[ 'fields' ][ 'voe_kategorie' ][ 'value' ]; if ( empty( $terms ) ) { // if there is nothing there set $term to null to avoid errors $terms = null; } else { if ( ! is_array($terms) ) { // create an array out of the comma separated values $terms = explode(',', $terms); } // ensure all values in the array are integer (otherwise the numerical value is taken as a new taxonomy term instead of an ID) $terms = array_map('intval', $terms); } wp_set_object_terms( $id, $terms, 'kategorie', false ); }
This is function perfectly.
But what if I wanna update a further taxonomy called “genre” from the field “voe_genre” in the same pod “release” ?
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘Update more terms with wp_set_object_terms’ is closed to new replies.