How to Obtain Custom Taxonomy ID and Convert to Int?
-
I’m having trouble obtaining the id of my custom taxonomy term, then converting it into a int to be used in wp_set_object_terms().
Here’s the code I’m using:
function default_cat($post_ID) { $terms = get_the_terms( $post->ID , 'control' ); if($terms) { foreach( $terms as $term ) { $cat_ids = array($term->term_id); $cat_ids = array_map('intval', $cat_ids ); } } wp_set_object_terms( $post_ID, $cat_ids, 'category' ); } add_action('publish_post', 'default_cat');
I keep getting an error about the second argument in array_map() not being an array. What am I doing wrong?
- The topic ‘How to Obtain Custom Taxonomy ID and Convert to Int?’ is closed to new replies.