I’m working on a project and would like to create a similar functionality that WordPress has for taxonomy.
I’m not quite sure how it all works though.
They have 3 tables that are related:
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?
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.
Any clarity would be awesome… really not seeing how this fits together. Thank you!
wp_term_taxonomy is a table in which you can define categories
hierarchy.
Below are description of fields
term_taxonomy_id = primary key(i think it is same as term_id most of the time)
term_id = reference key to term_id of wp_terms table.
taxonomy = type of category(category=post category, link_category= link category,post_tag = tags associated with posts, nav_menu = navigation menu, etc. )
parent = id of parent category
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