Custom Post Types and Taxonomies in Wordpress
One of the greatest geek features of Wordpress 3.0 is custom post types. Custom post types takes Wordpress from just a simple blog/page CMS to literally anything you want it to be. Instead of drafting a "post" you can create a "video" with it's own attributes like "actors", "director", etc. Combined with some fancy custom field work and you can build a backend system for a website tailored specifically for whatever the content of the site is instead of tailoring the content of your site to fit into a blog or page format. If you're willing to dive into a new level of geek, hold my hand and come along, it's not as difficult as it sounds. I've talked about wanting to know more and play with custom post types for a few weeks now so I figured as with many other things I would make DTLT Today my testbed for working it out. The site is a great example because while each episode as a post does work, I have to remember a lot of the same information from one episode to the next so having a post type called "Episode" that asks me for specific information and generates a new one just makes more sense. Here's what Wordpress will look like once we're done with it: Normally getting custom post types working in Wordpress would require code in your theme's functions.php file, but luckily as with many complex tasks, there's a plugin for this. I'm using Custom Post Type UI to give me an interface to quickly add a custom post type (and later a specific type of tag). After installing the plugin you just go into the Settings and give the custom post type a name (in my case "episodes") and it will create a new admin interface for creating episodes and keeping track of them. I should stop right here and point out that most themes for obvious reasons have a good understanding of posts and pages, but in order for your theme to display any information from these new custom post types you need to add that code to your existing theme. To have a whole page displaying that information you can follow this guide (but skip the first step since we created the post type with a plugin). There are other ways of grabbing specific information from these custom post types and displaying it within your theme, most just require a few lines of code in your existing theme. Just be aware that things can be a bit screwy at first. For example right now while DTLT Today looks great in a browser, the mobile plugin being used still only shows "Posts" and "Pages" but not my new "Episodes" which makes the website look empty. I'm also fairly certain the RSS feed is not working properly so I'll have to get that fixed. The next thing I wanted to have was a list of who appeared in each show. Similar to the tag system in Wordpress, you can create a custom taxonomy using the same Custom Post Type UI plugin. In my case I gave it the name "cast" and assigned it specifically to the "episode" post type. Now when I create a new episode I can quickly type (or show a list of the most popular) guests/hosts of each show. This also made it easy to display who was in a show underneath the episode page and each name links to a page that lists all the episodes they've been in. Sort of like the "author" page system in Wordpress but more flexible. The last piece of the puzzle was making the interface for adding information to an episode easier. By default a custom post type still displays the standard blog/page information: Title, Main Section, Tags, Comments, etc. To create some custom fields I found another great plugin called Custom Field Template that lets you setup a number of fields and lock it down to a specific post type (so it doesn't affect the page editing system). It's similar to building a form and the plugin gives you an example to go by. You can also turn on the HTML editor or the TinyMCE editor for text areas, which is useful if you need specific sections that can be styled but want basic information input on others. Again, to get this information to display in your theme you'll have to pull it in with specific php calls, your theme won't know how to show that extra information otherwise. To make things less confusing I went back to Custom Post Type UI and edited my post type to turn off a few things I didn't need, like the Title (which I dynamically create from two custom fields, Episode Number and Episode Title), Editor, Excerpts, Revisions, Author, etc. You can also use the Screen Options setting above the post editor to hide areas of the editing screen to make it feel very much like a customized CMS. As I play around with this stuff I see a lot of potential for using it with things like an art portfolio or data-driven site that has specific information entered many times with flexible ways to display it. It's definitely high-level work but the results are worth it and the availability of plugins that save the sanity of less-capable coders like yours truly are what make Wordpress a great system for this kind of work.