2

I want to understand terms and taxonomy in WordPress.

My questions:

  1. What are the terms and taxonomy in wordpress?
  2. How terms and taxonomy relates to post and how post, terms, taxonomy are stored in database ?
  3. What is the relationship between these three ?

My actual problem:

I have a site of real estate agency, my posts are stored as property, it has a different types of features, other fields like bedrooms, bathrooms, garage, rent or sale etc. Features has check-box and multiple answers.

So I want to implement the same functionality that Features has. I mean , I want to add new field , so that it can be seen and updated when property is updated.

  • This might not solve all your questions, but you can start here – Pieter Goosen May 27 '15 at 13:26
1
  1. What are the terms and taxonomy in wordpress?

From WordPress.org's Taxonomy Codex...

In WordPress, a "taxonomy" is a grouping mechanism for some posts (or links or custom post types)...

The names for the different groupings in a taxonomy are called terms.

Using groupings of animals as an example, we might call one group "birds", and another group "fish". "Fish" and "birds" are terms in our taxonomy.

This snippet can be read in detail on their page.

  1. how terms and taxonomy relates to post and how post , terms , taxonomy are stored in database.

In your database you get a number of tables relating to terms and taxonomy. They are, wp_term, wp_term_relationships, wp_term_taxonomy.

One taxonomy you will always have is a Category. For example, Uncategorised, is a Term within the Taxonomy. In your database then you will find that the wp_term_taxonomy has a term_id column, this is the foreign key, which is the primary key of the wp_term - this is how the taxonomy and the term are linked in the database. The wp_term_relationship table simple holds the post ID foreign key (as Object) and the term_taxonomy_id ... in essence this is a link table.

enter image description here

  1. What are the relationship between these three?

So you go to the Category page and make a new Category called 'New Cat'. You now have a Taxonomy (Category) and a Term (New Cat) ... you then make a post and add it to that Category, and now you have a Post linked to that Term and Taxonomy.

The 'category' taxonomy lets you group posts together by sorting them into various categories. These categories can then be seen on the site by using '/category/name' types of URLs. Categories tend to be pre-defined and broad ranging.

For your actual problem... you could potentially use the Categories to define aspects of the property such as location, property type (detached, semi, terraced) Alternatively you can look into utilizing the Tag taxonomy.

The 'post_tag' taxonomy is similar to categories, but more free form. Tags can be made up on the fly, by simply typing them in. They can be seen on the site in the '/tag/name' types of URLs. Posts tend to have numerous tags, and they are generally displayed near posts or in the form of tag clouds.

Also you can develop custom taxonomies however these require registering for you to use. You may find a plugin that could aid with this.

I'm not sure how much this helps with your actual problem but should give you some ideas and help you understand how they work.

  • You are not completely correct here. All taxonomies are meant to group posts, to create a relationship between them. The main diffirence between the taxonomy category and post_tag is, one is hierarchical, so the terms can have children which let you create more complex relationships, where as tags are non hierarchical and terms therefore can't have children – Pieter Goosen May 27 '15 at 13:30
  • Other than quoting from WordPress itself, everything I said was an example of, or database schema. I also said it can be read in more depth on the Codex. - the block quotes come from WP itself so... – Aravona May 27 '15 at 13:37
  • 1
    Don't always believe what the codex tells you, there are plenty of useless crap in the codex :-). I did not update the complete codex page when I added the 4th build in taxonomy and my image. May be it is time to properly update that page :-) – Pieter Goosen May 27 '15 at 13:43
  • Probably then as it's where people go for information - can't blame someone for getting it wrong is WordPress is showing the wrong thing? – Aravona May 27 '15 at 13:44
  • I think you misunderstood me :-), I did not blame you or attacked you for what you posted, I was just trying to help you. No harm intended. Unfortunately it is a fact that there are parts of the codex that is slightly wrong, or in some cases, completely wrong and my intention was to make you aware of that. – Pieter Goosen May 27 '15 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.