The custom post type functionality built into WordPress core allows you to create complex new content types with radically original and unique parameters that can be individually stored and queried later. You’ll be surprised how easy it is to look like a WordPress coding ninja when you start playing with this powerful framework.
Chris is a freelance WordPress theme and plugin developer, one half of the design studio Arcane Palette Creative Design, lead developer of WordPress theme shop Museum Themes and Project Manager for the event management plugin Event Espresso. In his free time, he makes electronic music.
Introduction and concepts Over the last five years, WordPress has been gaining traction, not just as a blogging platform, but also as a content management system. The ability to easily manage posts and pages and move them around with an intuitive admin has contributed greatly to this growth. But where WordPress really allows for creativity and experimentation and development is in the robust framework for developing completely new types of content beyond just blog posts and pages. This course is going to show you how to do that with three different frameworks to allow you to build unique content types for handling everything from a catalog of books, record releases, products, meeting notes, support documents, and more. We'll be talking about some of my favorite parts of WordPress, so this should be a lot of fun, and I hope you enjoy the ride.
Custom Meta Boxes WordPress comes prebaked with a cool feature called Custom Fields. This incredibly generic sounding feature is hidden by default. When enabled in the Screen Options panel, it displays a number of key input boxes along with the value text areas to go along with those keys. In the past, plugin and themed developers have used this to enable different features. These key value pairs get stored in the post meta table along with other information relevant to that post. Let's say I wanted to display what I was listening to under my post. I could use Custom Fields and create a key called listening_to. In the Value box I could put whatever was in my ITunes playlist at the moment, let's say M83. To display this, I would add some code to my single. php template file. It could go something like this. First, I check if the listening_to meta value exists. If so, I display that value next to a label that says Listening to. I could also create a filter on the content in a plugin to do this automatically so I didn't have to edit my single. php template. That might look like this. I could do this with other key value pairs as well. In fact, I could add as many keys as I wanted and use them in a wide variety of ways. All that information would get stored in the database and associated with that post. Once I've added the key once, it will show up as an option in the dropdown menu to add new Custom Fields. Alternately, I can just enter a new key value pair.
Custom Taxonomies On paper, taxonomies are not nearly as exciting as post types or even post meta. They don't make you look as awesome because there aren't flashy UI enhancements associated with taxonomies. Taxonomies do have their own page in the WordPress dashboard, but it displays the same as the categories or tags page and isn't as exciting as a custom meta box or a custom post type screen tailored to your specific situation. What taxonomies lack in flash, they make up for in utility. There are very few other ways to group posts of any type and none that would be more effective for SEO without significant coding. What's more, the interface for adding new terms is easy and familiar if you've been using WordPress for any amount of time. Taxonomies are best understood as a means to create organizational relationships between data and content. For example, you could use taxonomies to display a list of recipes by ingredients or bands by their band members. Why you could use categories or tags to organize things in this way, it wouldn't make as much sense as creating unique taxonomies.
Putting it All Together This module is going to be primarily a series of demos wherein we do stuff that combines a bunch of the different things I've talked about like adding custom meta boxes to custom post types and adding taxonomies to those custom post types and then doing stuff with those posts like displaying them with a short code. I'll also be talking more about how to create custom columns for your post types that pull in information from post meta and taxonomies and how to add icons for the menus and admin pages so they look less generic. Let's get started.