Categories, Tags, and Custom Fields (Oh My!)
WordPress is built to be dynamic and flexible enough for any use case. But this flexibility can introduce a large amount of confusion. WordPress provides a number of ways to do similar tasks which causes trouble for both new and veteran developers when trying to pick a particular method. Today we will look at the different ways WordPress allows developers to do a simple task: provide metadata. There are two main approaches: Taxonomies (i.e., Categories and Tags) and by creating Custom Fields.
But how do you decide when and where to use each type?
What Are They?
Taxonomies and custom fields provide users with the ability to define and group different types of content. You can use these groups to help users easily find and filter information on your website.
Tip: Use Categories and Tags to group types of content. Use Custom Fields for larger pieces of metadata.
Taxonomies
By default, WordPress includes two types of taxonomies: Categories and Tags. Ideally, use Categories to group larger buckets of information and Tags to define finer details and attributes.
For example, if working on a restaurant review site, you may have a separate blog post for each restaurant. You can use Categories to group similar restaurant types (e.g., Fast Food, Brunch, Diners, and Cafes). You can then use Tags to provide more detailed information (e.g., Price, Quality, Cuisine, and Pet-Friendliness). Visitors to your site can then find the prefect restaurant by selecting a combination of Categories and Tags.
Custom Fields
Custom Fields can provide similar grouping functionality as Categories and Tags. However, Custom Fields work best when used to ensure your writers provide consistent information when creating content.
You can leverage Custom Fields to provide a type of ‘roadmap’ for writers to follow when creating content. Using our restaurant review example, you can use Custom Fields to make sure each restaurant blog post contains the same, basic information (e.g., Open Hours, Address, Phone Number, and Website).
Tip: You can Custom Fields for almost any type of additional metadata. You can then provide this data to site visitors or simply use this information for custom behaviors behind the scenes. For example, a writer might populate Custom Fields with a Publish Date and an Archive Date. You can then create custom code that uses this value to automate the publishing cycle.
Conclusion
So now we know the different ways to provide metadata. But when to use each one? In general, think about how the metadata will be used and check this simple chart:
- Use Categories when grouping large items for website visitors to use. This might become your secondary navigation list. Try to limit a blog post to 1-2 categories.
- Use Tags for more detailed information your visitors will use. This may become navigation but more importantly will be used as one piece of multiple bits of information. Use Tags freely on each post.
- Use Custom Fields for key pieces of metadata especially on the backend. This is more about getting information from the authors to either present consistently across your site or to pass custom values to backend code.
With all things WordPress, these are presented as general guidelines and not hard and fast rules. As always, test, experiment, break things and rebuild. Because life (and coding) is a journey and not a destination.