Missing term_id and term_taxonomy_id when adding a term using wp_insert_term() function

The problem is the use of the php function list. If successful, wp_insert_term returns something of the form:

array(2) { ["term_id"]=> int(307) ["term_taxonomy_id"]=> int(325) }

You can’t use list with this as list only works for numerical arrays. Instead try extract instead:

extract($result);
echo "<p>The term <i>{$term_name}</i> under the <i>{$term_taxonomy}</i> taxonomy has been added into the <i>wp_terms & wp_term_taxonomy<i> tables. The Term ID is {$term_id} and the related taxonomy ID is {$term_taxonomy_id}.";

Leave a Comment

tech