Custom Post Types,Taxonomies, and Fields all enhance WordPress information architecture capabilities. Folks continue to be confused on what these things are and when to use them. Let’s present a use case to explain when best to use these powerful tools. This use case explains when to use these powerful tools.
Normal Everyday Blog Posts
When you post to your personal blog about what you’ve been doing today, it’s no big deal.
- Come up with a smarmy title
- Type out some witty commentary
- Add a couple photos
- Select a category such as “Home Life,” “Work Life, “ or “Play Life”
- Add a few tags detailing the post, such as “coffee,” “pizza,” “volleyball”
This goes on daily, and works great. Each blog post is an item of news about you.
Then You Start Geocaching…
Like you really needed another hobby, right? You start geocaching–searching for hidden treasure called “caches” with your GPS–and posting finds to your personal website. Sure, the geocaching site has a page for every find, where you get to claim your discovery. You want to add your own personal flavor, photos, and such to your own site, as well.
Common attributes for caches
All caches you find share a few common attributes. Each and every cache gets the following assigned to it:
- Difficulty: 1 to 10
- Size: Micro, Small, Medium, or Large
- Terrain challenge: 1 to 10
Uncommon attributes for caches
Your fabulous finds all have 4 other pieces of information you would like to keep track of. This information is almost always unique per cache. For example:
- Street address (if in city)
- Date and Time of the find
- URL of the cache on your geocaching club’s website
Time to upgrade your blog’s information architecture
You’re pretty smart, so you first realize you can add a “Difficulty” category to your blog, then add sub-categories for 1 through 10. You can do the same by adding a “Size” category and then adding sub-categories for “Micro,” “Small,” and so on.
- The list of available terms in your category list is going to get unwieldy.
- Having subcategories 1-10 under “Difficulty” and also under “Terrain” will result in some unwanted slugs in your permalinks.
- All these category terms will show as options everywhere in your blog–even when you’re just making a plain old daily personal update.
- There must be a more organized way to do this.
Adding Custom Taxonomies
After poking around, you find plugins and code to add your own custom taxonomies–which are like categories or tags, but with your own name and terms. You add taxonomies for “Difficulty,” “Size,” and “Terrain”–each with appropriate terms, like “Micro” and “Small” for “Size,” and so on.
Now, you can sort and display your posts by any of these criteria–such as viewing all with a size of “Micro.” Fantastic!
What’s that doing there?
Remember how picky you are? You make a new personal post about your kitty running away, and see these new taxonomy lists show up on your post editing page. Something seems odd about that. After all–if you’re writing about anything other than a cache find, none of those taxonomies are relevant. Sure, you could just leave them alone, checking nothing. You could hide them using Screen Options. The fact is, they are irrelevant, and don’t belong there.
Something must be done.
Adding Custom Post Types
No problem! The WordPress community is helpful, and you find plugins and code to create what are called Custom Post Types. You’re happy because a custom post type can be just like a regular post, but you can add and remove different features from it as needed.
You create a post type called “Caches.” Then, you edit the custom taxonomies you made earlier, and tell them to only show up for the “Caches” post type.
Awesome. No more extraneous, irrelevant taxonomies littering your normal Post edit screens!
Managing custom fields
You find a great cache in the hills outside of town, and go to post it to your blog right away. You create a new “Cache” entry and start filling in the details. That’s when you realize you forgot to account for the find’s latitude / longitude, altitude, and other data you want to record. You think about just adding this at the end of the post’s content, but then you realize you’d never be able to sort, search, and compile your posts based on any of this data in the future. To do that, you need to capture this data in specific fields–not just lump it in after the content.
Sign up for more
Default custom fields entry
No problem. You start to use the “Custom Fields” in your edit screen to add these data. That’s sort of ugly though, don’t you think?
Surely, there must be a better way.
Specialized custom fields entry
Hitting up the WordPress community once again, you find a plugin that helps you create special areas in edit screens for custom fields. You can insert special fields for adding files, inserting dates, choosing from radio buttons, checkboxes, and menus. And the icing on the cake? You can tell your custom post type called “Cache” to include these special fields–and you can leave the fields off of every other post type, where they are irrelevant anyway!
The world’s greatest website (says your mom)
There you have it–your personal blog evolved from “news about you,” to adding specific data about the special caches from your geocaching adventures. Since you can control what taxonomies and fields show up for each post type, you won’t have to skip past all those Cache-specific fields tonight when you make a normal post about finding your kitty cat!
Simple information architecture choices in summary
Your use cases may differ greatly when considering whether or not to use these custom tools. Wrap your brain around the following 3 guidelines, and you’ll probably come out okay.
- When numerous posts can be classified by a meaningful attribute (like Size,) it’s probably worth creating a custom taxonomy for that attribute.
Taxonomies are like adjectives that can be applied to numerous items on your site.
- When posts need assigned data that’s almost always unique amongst other posts (like Address,) it’s probably worth creating a custom field for that data.
Custom fields are like adjectives that only apply to individual items on your site.
- When numerous posts are about a specific thing (like Cache) that always involves the same taxonomies and custom fields it’s probably worth creating a custom post type for that thing.
Post types are like nouns. The main reason for a new post type is its unique characteristics that can’t be neatly packaged any other way.
- Featured Image Credit: http:[email protected]/5051751548 (Yandle)
- Geocaching Image Credit: photo by:luis perez