I'm working on a project and would like to create a similar functionality that Wordpress has for taxonomy.
我正在开发一个项目,并希望创建一个与Wordpress一样的分类功能。
I'm not quite sure how it all works though.
我不太确定它是如何工作的。
They have 3 tables that are related:
他们有3个相关的表:
wp_terms (
term_id,
name,
slug,
term_group
)
wp_term_taxonomy(
term_taxonomy_id,
term_id,
taxonomy,
description,
parent,
count
)
wp_term_relationships(
object_id,
term_taxonomy_id,
term_order
)
From what I can tell, object_id is a generic name for what is either a link_id or post_id, but how do you know which one it is to query against it?
据我所知,object_id是link_id或post_id的通用名称,但是你怎么知道查询它的是哪个?
It also seems like wp_terms could be combined with wp_term_taxonomy. wp_term_taxonomy has the 'taxonomy' column, which is 'category' or 'link_category' by default, but other than that it just seems to reference the term_id, which has the slug and name.
似乎wp_terms可以与wp_term_taxonomy结合使用。 wp_term_taxonomy有'taxonomy'列,默认情况下是'category'或'link_category',但除此之外它似乎只是引用了term_id,它有slug和name。
Any clarity would be awesome... really not seeing how this fits together. Thank you!
任何清晰度都会很棒......真的没有看到它如何组合在一起。谢谢!
1 个解决方案
#1
3
- assume that wp_terms is a master table of category.
- 假设wp_terms是类别的主表。
-
wp_term_taxonomy is a table in which you can define categories hierarchy. Below are description of fields
wp_term_taxonomy是一个表,您可以在其中定义类别层次结构。以下是字段说明
term_taxonomy_id = primary key(i think it is same as term_id most of the time)
term_taxonomy_id =主键(我认为大多数时候它与term_id相同)
term_id = reference key to term_id of wp_terms table.
term_id = wp_terms表的term_id的引用键。
taxonomy = type of category(category=post category, link_category= link category,post_tag = tags associated with posts, nav_menu = navigation menu, etc. )
taxonomy =类别类型(category = post category,link_category = link category,post_tag =与帖子相关的标签,nav_menu =导航菜单等)
parent = id of parent category
parent =父类别的id
-
assume that wp_term_relationships is a relationship table of product and category. where
object_id is product id and term_taxonomy_id is category id
假设wp_term_relationships是产品和类别的关系表。其中object_id是产品ID,term_taxonomy_id是类别ID
#1
3
- assume that wp_terms is a master table of category.
- 假设wp_terms是类别的主表。
-
wp_term_taxonomy is a table in which you can define categories hierarchy. Below are description of fields
wp_term_taxonomy是一个表,您可以在其中定义类别层次结构。以下是字段说明
term_taxonomy_id = primary key(i think it is same as term_id most of the time)
term_taxonomy_id =主键(我认为大多数时候它与term_id相同)
term_id = reference key to term_id of wp_terms table.
term_id = wp_terms表的term_id的引用键。
taxonomy = type of category(category=post category, link_category= link category,post_tag = tags associated with posts, nav_menu = navigation menu, etc. )
taxonomy =类别类型(category = post category,link_category = link category,post_tag =与帖子相关的标签,nav_menu =导航菜单等)
parent = id of parent category
parent =父类别的id
-
assume that wp_term_relationships is a relationship table of product and category. where
object_id is product id and term_taxonomy_id is category id
假设wp_term_relationships是产品和类别的关系表。其中object_id是产品ID,term_taxonomy_id是类别ID