2011-04-11 53 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 
相关问题