假设你有一个很好的单词列表,你可以很容易地创建一个array
使用它们,执行一些数据操作。
之后,您可以通过$array
并相应插入术语:
$yourcities = file($filename, FILE_IGNORE_NEW_LINES); // all your valuesfrom the .txt file
foreach( $yourcities as $thiscity ) {
wp_insert_term(
$thiscity, // the term, in your case the name of the city
\'category\', // the taxonomy, in your case category
array(
\'description\'=> \'\', // if available
\'slug\' => \'\', // leave blank if not available
\'parent\'=> $parent_term_id // if you do it hierarchical, be sure to insert the parent ID here
)
);
}