检查线路;list($term\\u id,$taxonomy\\u id)=$result在下面的代码段中。(朝向底部)。为什么我缺少术语\\u id&;当我回显$taxonomy\\u id的值时?它们不应该由wp\\u插入它们来填充吗?
$term_name = \'Uncategorized\';
$term_slug = sanitize_title(\'Uncategorized\', \'Default category slug\');
$term_taxonomy = \'category\';
$term_description = $term_slug . " desc here.. ";
$term_parentID = 0;
if ( is_term( $term_name , $term_taxonomy ) ):
echo "this term exists!";
die;
else:
//echo "This terms does not exist!";
//echo "<pre>";
//global $wp_taxonomies;
//print_r ($wp_taxonomies);
//echo "</pre>";
if (taxonomy_exists($term_taxonomy)):
//insert the term into the wp_terms
$args = array(
\'description\' => $term_description,
\'slug\' => $term_slug,
\'parent\' => $term_parentID
);
$result = wp_insert_term($term_name, $term_taxonomy, $args);
if ( is_wp_error( $result ) ):
$error_string = $result->get_error_message();
echo \'<div id="message" class="error"><p>\' . $error_string . \'</p> </div>\';
else:
list($term_id,$taxonomy_id) = $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}.";
//outputs as The term Uncategorized under the category taxonomy has been added into the wp_terms & wp_term_taxonomy tables. The Term ID is and the related taxonomy ID is .
endif;
else:
echo "<p>{$term_taxonomy} does not exist. we cannot add this $term. Please use the register_taxonomy function to register this taxonomy. ";
endif;
endif;