Wordpress Taxonomy - How to find out which object_id?

I am working on a project and want to create the same functionality that Wordpress has for taxonomy.

I'm not quite sure how it all works.

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 common name for what is either link_id or post_id, but how do you know which one it should request?

It also seems that wp_terms can be combined with wp_term_taxonomy. Wp_term_taxonomy has a taxonomy column, which by default is a category or link_category, but other than that it just refers to term_id, which has a slug and a name.

Any clarity would be awesome ... not really seeing how it fits together. Thanks!

+6
source share
1 answer
  • Suppose wp_terms is the main category table.
  • wp_term_taxonomy is a table in which you can define hierarchy categories. Below are descriptions of the fields

    term_taxonomy_id = primary key (I think it is the same as term_id most of the time)

    term_id = reference to the term_id of the wp_terms table.

    taxonomy = category type (category = category post, link_category = link category, post_tag = message tags, nav_menu = navigation menu, etc.)

    parent = id of parent category

  • Suppose wp_term_relationships is a table of product and category relationships. where object_id is product id and term_taxonomy_id is category id

+3
source

Source: https://habr.com/ru/post/897845/


All Articles