admin管理员组文章数量:1430606
I am a PHP developer and recently I am trying to build a platform which needs lots of categories/filters/tags some in hierarchy some not.
So the question is...
I am able to manage terms in these tables
terms
, terms_metadata
and terms_relationships
, but there is another table in WordPress - terms_taxanomymy
.
What is the significance of defining another table for just storing "parent", "type", "count" and "description" when you can do that in terms
table itself.
I am a PHP developer and recently I am trying to build a platform which needs lots of categories/filters/tags some in hierarchy some not.
So the question is...
I am able to manage terms in these tables
terms
, terms_metadata
and terms_relationships
, but there is another table in WordPress - terms_taxanomymy
.
What is the significance of defining another table for just storing "parent", "type", "count" and "description" when you can do that in terms
table itself.
1 Answer
Reset to default 6Well, it uses 3 tables. The fourth one (wp_termmeta
) is just a way of allowing you to store some meta values for terms (icons, additional descriptions and so on).
Citing from Codex:
- wp_terms - The categories for both posts and links and the tags for posts are found within the wp_terms table.
- wp_termmeta - Each term features information called the meta data and it is stored in wp_termmeta.
- wp_term_relationships - Posts are associated with categories and tags from the wp_terms table and this association is maintained in the wp_term_relationships table. The association of links to their respective categories are also kept in this table.
- wp_term_taxonomy - This table describes the taxonomy (category, link, or tag) for the entries in the wp_terms table.
So the only part that may be confusing is that there are separate tables for terms and term_taxonomy... And it can be confusing, because it has lost its meaning nowadays.
But before WP 4.2.2 (I guess) the approach to terms was a little bit different - terms were unique across wp_terms
table.
So if you had “books” as category and “books” as tag, then there was only one record with “books” in wp_terms
and obviously 2 records in wp_term_taxonomy
.
But when the wp_termmeta
table was introduced it would make it confusing - so such terms were split. And today, for the example above, you’ll have two separate rows in wp_terms
table.
本文标签: phpWhy WordPress uses 4 tables to manage terms
版权声明:本文标题:php - Why WordPress uses 4 tables to manage terms 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745555661a2663171.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论