此信息可能會幫助您瞭解term_id和term_taxonomy_id的工作方式。似乎有很多條件影響了如何設置ID的最終結果。
看到完整的參考這裏:http://phpxref.com/xref/wordpress/wp-includes/taxonomy.php.html#wp_insert_term
也有看this trac ticket就需要有一個職位關係表和一些用例。
get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') X-Ref
Get all Term data from database by Term ID.
The usage of the get_term function is to apply filters to a term object. It
is possible to get a term object from the database before applying the
filters.
$term ID must be part of $taxonomy, to get from the database. Failure, might
be able to be captured by the hooks. Failure would be the same value as $wpdb
returns for the get_row method.
There are two hooks, one is specifically for each term, named 'get_term', and
the second is for the taxonomy name, 'term_$taxonomy'. Both hooks gets the
term object, and the taxonomy name as parameters. Both hooks are expected to
return a Term object.
'get_term' hook - Takes two parameters the term Object and the taxonomy name.
Must return term object. Used in get_term() as a catch-all filter for every
$term.
'get_$taxonomy' hook - Takes two parameters the term Object and the taxonomy
name. Must return term object. $taxonomy will be the taxonomy name, so for
example, if 'category', it would be 'get_category' as the filter name. Useful
for custom taxonomies or plugging into default taxonomies.
param: int|object $term If integer, will get from database. If object will apply filters and return $term.
param: string $taxonomy Taxonomy name that $term is part of.
param: string $output Constant OBJECT, ARRAY_A, or ARRAY_N
param: string $filter Optional, default is raw or no WordPress defined filter will applied.
return: mixed|null|WP_Error Term Row from database. Will return null if $term is empty. If taxonomy does not
get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw') X-Ref
Get all Term data from database by Term field and data.
Warning: $value is not escaped for 'name' $field. You must do it yourself, if
required.
The default $field is 'id', therefore it is possible to also use null for
field, but not recommended that you do so.
If $value does not exist, the return value will be false. If $taxonomy exists
and $field and $value combinations exist, the Term will be returned.
param: string $field Either 'slug', 'name', or 'id'
param: string|int $value Search for this term value
param: string $taxonomy Taxonomy Name
param: string $output Constant OBJECT, ARRAY_A, or ARRAY_N
param: string $filter Optional, default is raw or no WordPress defined filter will applied.
return: mixed Term Row from database. Will return false if $taxonomy does not exist or $term was not found.
get_term_children($term_id, $taxonomy) X-Ref
Merge all term children into a single array of their IDs.
This recursive function will merge all of the children of $term into the same
array of term IDs. Only useful for taxonomies which are hierarchical.
Will return an empty array if $term does not exist in $taxonomy.
param: string $term ID of Term to get children
param: string $taxonomy Taxonomy Name
return: array|WP_Error List of Term Objects. WP_Error returned if $taxonomy does not exist
你還在試圖解決這個問題嗎?如果是這樣,我可能願意仔細看看。 – tollmanz 2011-04-27 05:47:41
你在屏幕截圖中顯示了哪些表格?我從來沒有在wordpress db中看到類似的。你有什麼版本的wordpress?你使用插件來創建分類嗎? – Joeyjoejoe 2011-05-19 23:05:15