2011-04-11 79 views
2

首先,最重要的是,我需要強調我非常感謝任何花時間回覆的人 - 事先謝謝,謝謝,謝謝!WordPress的'自定義帖子類型'被設置爲錯誤分類術語ID

我覺得照片是偉大的服務來解釋的事情,所以要開始,這裏的問題的說明的東西:

http://i.stack.imgur.com/b9OXR.png

前言:

  • 我的網站根據「dir_listing」自定義帖子類型有大約400個帖子
  • 每個「dir_listing」帖子都可以與「listin摹類別」自定義分類和/或 「listing_region」 自定義分類
  • 我有大約210 「listing_category」 條款,以及155 「列表區域」 條款

在總結問題:

當發佈或更新「dir_listing」帖子類型時,有時術語ID會被記錄到'term_relationships'表中而沒有問題,其他時間會被錯誤記錄。即使如此,當我回到編輯「dir_listing」帖子類型之一時,正確標記了所需的父/子詞條的複選框。

可能相關的操作?

  • 一些「listing_category」條款已經打亂了。 (例如,父項已成爲子項,反之亦然,或者子項已移至另一個父項。)

  • 父項&子項條款已更名,未對「dir_listing」郵政類型。 (我認爲這不重要,因爲帖子應該通過ID#與條款相關聯)

  • 許多家長條款和子條款可能已被其他管理員級別用戶刪除。這似乎也發生在「listing_regions」分類的Child-Term上。

我如何分析/試圖修復它:

  • 廣泛地搜索到WordPress的TRAC(報道有類似的問題)

  • 谷歌搜索的東西像*「的WordPress tax_input bug「*,」wordpress taxonomy id bug「,」wordpress定製分類錯誤「等並沒有發現匹配問題

  • 禁用所有插件,定製重寫,和其他分類

  • 保證了複選框上輸入了正確的分類作爲他們的「名」和期限ID作爲他們的「價值」

  • 攻擊/wp-admin/includes/post.php核心文件以嘗試自行修復它。 (沒有運氣。)

  • 發佈問題[WordPress的 「使用說明和故障排除」 論壇] [3]今天上午

  • (沒有回覆)

  • 發佈問題到Reddit討論社區/ R/web_design今天下午(也沒有回覆)

我已經花了8個小時的大部分時間試圖確定這種情況的原因,如果我缺少一個步驟,通過使用自定義MySQL查詢直接拿到名單與特定術語ID相關的帖子。

再次,任何想法或建議任何人都可能有非常讚賞 - 謝謝!

+1

你還在試圖解決這個問題嗎?如果是這樣,我可能願意仔細看看。 – tollmanz 2011-04-27 05:47:41

+0

你在屏幕截圖中顯示了哪些表格?我從來沒有在wordpress db中看到類似的。你有什麼版本的wordpress?你使用插件來創建分類嗎? – Joeyjoejoe 2011-05-19 23:05:15

回答

0

此信息可能會幫助您瞭解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 
相關問題