The Hidden Value Of Custom Taxonomies
The Hidden Value Of Custom Taxonomies
Join the DZone community and get the full member experience.Join For Free
Java-based (JDBC) data connectivity to SaaS, NoSQL, and Big Data. Download Now.
When people tell me they are about to embark on a web project, being the technology nerd that I am, I usually ask them about how they will implement it (or usually how they have implemented it). And when they tell me they have used this or that technology and not WordPress I always have to hold myself back. One, because I come across as a techie busy body and two, because it’s never polite to tell your friend they could have done the job better using WordPress.
Two of the features which are under used and not understood by a large number of users of WordPress are custom taxonomies and custom post types. If you mention the word ‘Taxonomy’ to the average WordPress user, their eyes start glazing over and the conversation goes downhill from there. If you ever want to get out of a conversation at a dinner party, just start talking about custom taxonomies and you will see what I mean. (A caveat to that is if you are at a dinner party at a WordCamp).
In this post I am going to talk mainly about custom taxonomies. I am also going to use the following scenario.
Say I have just started a niche website called WordCamp holiday homes. The idea behind the site is to allow people to find somewhere to stay while they’re at a WordCamp. Now version 1 of this website is written in straight PHP with a MySQL backend. The system isn’t too dumb, it picks up the RSS feed from the WordCamp website so we can list the location of current WordCamps. People who want to include their a rental property on the site they can log in and manage their own listing, the renter can add the region and what type of room or property they are renting out, using tags. Now the down side to this is that people being people, when a renter adds tags to
their listing then they could put almost anything in. So the system needs to pick up the tag, see if there is a similar one and then suggest the tag that was found. This will save the admin having to put in tags and then adding more if a renter wants to add a tag which doesn’t exist.
So how does WordPress fit into to all this? Well building all this from scratch
would be a reasonably sized chunk of work, let alone then making the site look good and a lot of the functionality described above comes out of the box if you use WordPress.
But as this post is about custom taxonomies then we shall focus on that part. We want a renter to mark their listing with the region the rental is in. We allow the renter to add a listing which is in fact a custom post type as far as WordPress is concerned. So we create a taxonomy called Region, and then allow the renters to add terms to that taxonomy(in case you are not aware the terms are the bits you add to a taxonomy, for the Tags taxonomy, the term is a tag). Now other than adding the new taxonomy WordPress will do the rest of the work for us. It simply works that way out of the box.
Let’s say we also want to ask the renter to mark their rental with what facilities are available. Again we can create a custom taxonomy and allow the renter to add often used terms, or allow them to add new ones. Again with WordPress this all comes out of the box.
Now why not simply use tags or categories? Well this could get confusing and make it hard to find the desired the tag or category. By creating custom taxonomies, renters can add terms or use current ones, and it keeps everything nicely separated.
As with any tool the custom taxonomies should be appropriate for what is trying to be achieved with the site. If there are too many then it will make the site confusing and be more of a hindrance to usability than a help.
Do you use custom taxonomies? If you do I would love to hear about how you use them and why.
Published at DZone with permission of Chris Odell , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.