WordPress“自定义帖子类型”设置了错误的分类术语 ID
首先,也是最重要的,我需要强调,我非常感谢任何花时间回复的人 - 提前谢谢您,谢谢您!
我觉得图片对于解释事物很有帮助,所以首先,这里有一些问题的说明:
https://i.sstatic.net/b9OXR.png
前言:
- 我的网站在“dir_listing”自定义帖子类型下有大约 400 个帖子
- 每个“dir_listing”帖子都可以与条款相关联从“列表类别”自定义分类法和/或“listing_region”自定义分类法中,
- 我有大约 210 个“listing_category”术语和 155 个“列表区域”术语
问题摘要:
在发布或更新“ dir_listing”帖子类型,有时术语 ID 会毫无问题地记录到“term_relationships”表中,而其他时候则记录错误。
即便如此,当我返回编辑“dir_listing”帖子类型之一时,所需父/子术语的复选框已正确标记。
可能相关的操作?
许多“listing_category”术语已被改组。 (例如,父术语已成为子术语,反之亦然,或者子术语已移至另一个父术语。)
- )子条款已重命名,但未对“dir_listing”帖子类型进行任何更改。 (我认为这并不重要,因为帖子应该通过 ID 号与条款相关)
许多父条款和子条款可能已被其他管理员级别用户删除。 “listing_regions”分类法的子条款似乎也会发生这种情况。
我如何调查/尝试修复它:
广泛搜索 WordPress trac(未报告类似问题)
搜索 Google对于诸如 *“wordpresstax_input bug”*、“wordpress 分类法 ID 错误”、“wordpress 自定义分类法错误” 等,但没有发现匹配的问题
禁用所有插件、自定义重写和其他分类法
禁用确保复选框输入具有正确的分类法作为其“名称”和术语 ID 作为其“值”< /p>
破解了 /wp-admin/includes/post.php 核心文件以尝试自行修复。 (不走运。)
今天早上已将问题发布到 [WordPress“操作方法和故障排除”论坛][3](没有回复)
今天下午在 Reddit /r/web_design 发布了问题(也没有回复)
我已经花了8 个小时的大部分时间试图确定其原因,或者如果我错过了使用自定义 MySQL 查询直接获取与特定术语 ID 相关的帖子列表的步骤。
再次强调,非常感谢任何人的想法或建议 - 谢谢!
First and foremost, I need to stress how greatly I appreciate anyone who takes the time to respond - In advance, thank you, thank you, THANK YOU!
I feel pictures are of great service to explaining things, so to start off, here's something of an illustration of the issue:
https://i.sstatic.net/b9OXR.png
Preface:
- My site has about 400 Posts under the "dir_listing" Custom Post Type
- Each "dir_listing" Post can be associated with Terms from the "listing category" Custom Taxonomy and/or "listing_region" Custom Taxonomy
- I have about 210 "listing_category" Terms, and 155 "listing region" Terms
The Issue in Summary:
When Publishing or Updating a "dir_listing" Post Type, sometimes the Term IDs get recorded into the 'term_relationships' table without issue, and other times are recorded erroneously.
Even so, when I go back to edit one of the "dir_listing" Post Types the checkboxes for the desired Parent/Child Terms are correctly marked.
Actions that could be Related?
A number of the "listing_category" terms have been shuffled around. (e.g. A Parent term has become a Child term, or vice-versa, or a Child term has been moved to another Parent.)
Both Parent & Child Terms have been renamed without making any changes to the "dir_listing" Post types. (I don't think this matters, since Posts are supposed to be related to Terms by ID #)
A number of Parent Terms and Child Terms may have been deleted by another Admin-level user. This also seems to happen with Child-Terms of the "listing_regions" taxonomy.
How I've Investigated / Tried to Fix It:
Extensively searched WordPress trac (No similar issues reported)
Searched Google for things like *"wordpress tax_input bug"*, "wordpress taxonomy id bug", "wordpress custom taxonomy bug", etc. and found no matching issues
Disabled all plugins, custom rewrites, and other taxonomies
Ensured the checkbox inputs had the correct Taxonomy as their 'name' and Term ID as their 'value'
Hacked the /wp-admin/includes/post.php core file to try to fix it myself. (No luck.)
Posted issue to [WordPress "How-To and Troubleshooting" forum][3] this morning (No replies)
Posted issue to Reddit /r/web_design this afternoon (Also no replies)
I've spent the better part of 8 hours trying to determine the cause of this, or if I'm missing a step by using a custom MySQL query to directly get a list of Posts related to a particular Term ID.
Again, any thoughts or suggestions anyone might have are VERY MUCH appreciated - Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此信息可能会帮助您了解 term_id 和 term_taxonomy_id 的工作原理。似乎有很多条件会影响 id 设置方式的最终结果。
请参阅此处的完整参考: http://phpxref.com/xref /wordpress/wp-includes/taxonomy.php.html#wp_insert_term
另请参阅 此 trac 票证涉及帖子关系表的需求和一些用例。
This info might help you with how the term_id and and term_taxonomy_id work. It seems like there are a lot of conditions that effect the final outcome of how the ids are set.
See the full reference here: http://phpxref.com/xref/wordpress/wp-includes/taxonomy.php.html#wp_insert_term
Also have a look at this trac ticket regarding the need for a posts relationship table and some of the use cases.