Taxonomies From Object Oriented Perspective

In the world of object oriented modeling, we look at the general case of an object and the characteristics that define that general case. We then define specific cases especially those which have different attributes or different behaviors from the general case, but that still meet the definition of the general case.

WordPress categories, tags and taxonomies fall into this realm very nicely. Taxonomies are the general case of a data type. The characteristics of a taxonomy is that it is a datatype to help describe the content of a post and that certain other posts will have content that is associated with the other posts. So one of the behaviors of the datatype of taxonomy is that it display all the posts that use a particular value of the taxonomy and that we can then manipulate the display based on that value. Every taxonomy has a name and may have child taxonomies.

So in WordPress, a category is a type of taxonomy. All the years that I have been using WordPress categories, I did not realize it was of a specific datatype called taxonomy. So category is one specific definition of a taxonomy.

Tags are another type of taxonomy. Again tags are datatypes (taxonomies) we associate with certain content to easily search on those posts containing that content. One of the main differences between tags and categories is that a tag does not necessarily describe the content but is instead used as an alert to other viewers who would be interested in that content. So while the content of a post may be talking about how the legal system is oppressive, the tag #christian would bring out this content to the viewer who wants to see content that would be of interest to a christian. This is not necessarily the only reason to use tags, but it is main one. The problem is we don’t know all the tags that exist today (and sometimes we accumulate many on our sites!), but with a little research, ingenuity and cleverness we can devise some that would eventually accomplish the goal of popping up in someone’s search results. Tags allow the posts which aren’t always in the same category to also be connected.

The beauty in the taxonomy class is the behavior associated with every one that is defined. Click on any taxonomy and you will instantly get a display of all other posts on the site that use that same taxonomy. This occurs both for tags and categories and subcategories. The problem is the website developer has to understand how the behavior works to use it effectively. And if you have subcategories, both the parent and the subcategory must be associated with a post if the post is to be included in the display of either the parent or the subcategory. Many site developers miss this and only check the box next to the subcategory forgetting the parent category. If the developer doesn’t want the parent to ever be displayed as a group of posts, then this is ok. But many shortsighted developers start with that limited scope and then later need to include the parent and don’t understand why the parent taxonomy has no posts. But with training and experience we can learn how to use taxonomies effectively to help in site flexibility and in site search optimization.

Today in WordPress we also have the ability to create additional taxonomies. Wow! How powerful is that?! Well it is very powerful for the website developer who has had trouble in the past of trying to deal with hierarchical and overlapping categories. For instance pet could be a category, dog, cat, horse, hampster, and rock could all be sub categories of the category pet. Then you may want to categorize by indoor or outdoor, or male or female. Yikes! Well this is where additional taxonomies come into play. Add to this that your site may also be displaying yard designs and have tables and classify them as indoor and outdoor. Now when someone using the power of taxonomies wants to display all posts associated with outdoor, they will get the outdoor tables and the outdoor pets! Oooops!! To alleviate that the developer has to define outdoor-tables and outdoor-pets separately. That works. The problem is that categories and tags are site defined, and selected by the post author.

But with the new definition of taxonomies we can assign certain taxonomies to specific types of posts. In other words we can create post defined categories; categories that are specific to a particular type of post. So a post about furniture will have the taxonomy of location assigned to it and given the value of outdoor. Then the pet posts would have a taxonomy of environment assigned to it and given the value of outdoor. Now when the viewer is reading a pet post and clicks on the outdoor taxonomy, only the pet posts with outdoor selected as the environment will be displayed. And when the post is being created, the author must first decide if this is a post about pets or a post about furniture, and the taxonomy will be associated with that particular type of post. So if the post is about pets, the author would add a new pet-post and if it was about furniture he would add a new furniture-post. Now the author can also post about pet furniture and specifically state if the furniture is best for outside or inside locations. Now only the taxonomies assigned to the specific post type would be available during the composition and editing of the post.

I don’t know when the WordPress developers first introduced this wonderful capability, but I’m glad they did. I just started using it along with the post-type builder in my favorite theme – Themify Parallax.

Hope this makes sense and was valuable. Leave me a comment if you have questions or like using taxonomies as well.