I’ve been happily tinkering with the beta version of WordPress 3, down in the bowels of the code, mixing unmarked vials of PHP over open flames, etc for a brand new NMC site. The main thing I have been working on are exploiting the feature to create my own types of content with their own properties.
Essentially up to know you could create two kinds of content- posts and pages, with pretty much the same feature. Any additional descriptors one wanted to add needed to be done via custom fields. The idea is now, I could create a kind of content, say to build an encyclopedia of dogs, and use all of the WordPress features to make an entry (title, post/content, tags). But to my Dog content type, I could also add additional fields, like radio buttons to classify them by “small”, “medium”, or “large”, a field to enter a URL for an outside reference, a menu to classify my breed, etc.
My Dog content type would live outside the blog content, so they would not appear as posts, but I could create templates to display them and the additional data, I could build sidebar widgets, I can make archives, do all kinds of things.
Before I slip too much into jargon, let me say that everything I have done is by hand coding, and is not meant as the means this will likely be done in the future. Almost certainly plugins will develop to make what I have done much easier, though, in the code, you have the most flexibility. My purpose was (a) to show this as a concept that works; and (b) get a site up that needed to happen fast.
In learning to do this, I relied on a number of blog posts I found (see below); but no single post really covered it all, and most presented conceptual sites using content types, not a real one (and they always seem to use movies as an example?).
I will first show and talk about the (almost, ’cause its never quite done) final site. This is for a new NMC project, the Marcus Institute for Digital Education in the Arts (MIDEA) which is at http://midea.nmc.org/
A few notes about this site:
- It was meant to be heavy on the visuals. For themes, I started looking at the “magazine” type ones, and actually, for the first time, paid to get access to a premium theme- this is Modularity from Graph Paper Press (note they offer a free version that would do fine for many sites). I was inspired when I saw the theme in use at Sciberia.
However, as I will detail in a later post, I have heavily customized the theme- to me a theme is not the end, but just the beginning.
- Part of the site is just a blog, we have guest bloggers post what we call “ideas” and we also use the blog to do news. These are segregated just by categories.
- The first custom content type is for Organizations these are museums that are participating in this project. The items added to the basic title/description/featured image were things like the museum’s web site URL, their facebook, twitter links if applicable, a field for their physical address, and latitude/longitude for putting them on a map. In a future post I’ll talk about the great geomapping plugin I use, which I’ve even stretched to dynamically map all organizations on a single map.
- The second content type is for projects these museums have done or will be doing. What was added was a again a URL to view the project. But what was neat is once we had the organizations in as content, I could add a menu to the project editor form to associate the project with its museum. We also have an internal ranking of the projects which we can use around the site to list just ones of a certain number. The beauty in all this is that it makes it easy for people running our project to enter and edit data; you are able to even customize the editing screen (like you normall see for posts) to use the custom data
- The last content type is for events – things that sould go on a calendar, so the extra fields include a start and end date/time so we can display it in sidebars and also order appropriately on displays.
The biggest steps were in making modifications to templates to display the content as needed, which led to a number of approaches for running custom queries, doing multiple loops, and more fun. So what I hope to cover in a series of posts next are:
- Overview WordPress 3.0 Content Types– my plans to dive in
- Creating the content types. The easiest part
- Leveraging child themes– my newly discovered best practice for chopping apart themes.
- Adding the meta data field editing boxes (add_post_meta). Hacking the Editing fields.
- Modifying templates to display the content, Hacking the templates.
You can find all the posts in this series at http://cogdogblog.com/2010/07/23/roundup-wp3/
Stick around for the code fun.
My key learning resources for this were:
- Konstantin’s overviews were a great insight into the possibility Custom Post Types in WordPress 3 and Extending Custom Post Types in WordPress 3.0
- WP Engineer’s First Impressions of Custom Post Type
- Justin Tadlock’s Custom post types in WordPress
- Ballyhoo Blog’s Custom Post Types WordPress 3.0 with template archives for showing me how to set up the redirect’s and ideas on templating.
- Genuine Juice Adding Custom Field GUI to Custom Post Types in WordPress 3.0 was indispensible for learning how to build the additional form fields for editing my content types.
- WordPress Codex for Register Post Types, add_meta_box
The genuine juice article on the custom post types was impossible to follow and left out key information. can you please clarify how that works, because those people certainly can’t.
Yep, that’s why I did this series, but there is no guarantee I did any better. The index to my posts on this are found via