Skip to content

Commit

Permalink
check wp error
Browse files Browse the repository at this point in the history
  • Loading branch information
torounit committed Nov 15, 2023
1 parent 1bba46a commit f79a934
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,14 @@ private function insert_initial_term( $term ) {
$args['parent'] = absint( $term_id );
}
$result = wp_insert_term( $term->name, $this->name, $args );
if ( $result['term_id'] ) {
foreach ( $term->meta as $meta_key => $meta_value ) {
add_term_meta( $result['term_id'], $meta_key, $meta_value, true );
if ( ! is_wp_error( $result ) ) {
if ( $result['term_id'] ) {
foreach ( $term->meta as $meta_key => $meta_value ) {
add_term_meta( $result['term_id'], $meta_key, $meta_value, true );
}
}
}

}
}

Expand Down

0 comments on commit f79a934

Please sign in to comment.