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!
term_id is the ID of a term in the terms table. taxonomy designates the taxonomy in which the term resides. The default taxonomies are category , link_category , and post_tag . term_taxonomy_id is a unique ID for the term+taxonomy pair.
The wp_term_taxonomy table stores more data about terms as well as the taxomies they are part of. It has six fields: term_taxonomy_id stores an ID for the record in this table. term_id represents the ID of the term, linked to its record in wp_terms. taxonomy is the name of the taxonomy which the term is in.
A term is an individual tag or category within a taxonomy. Imagine you have a custom taxonomy for a doctor's specialty. A term would be one specific category within your taxonomy, such as “Pediatrics.” By default, WordPress creates a term archive view.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With