Before I get into the techniques of creating custom post types, I want to step back and look at the larger issue of custom content.
Custom Post Type < > Custom Content
The title of this series is “Dive into WordPress Custom Post Types”.
But I cannot emphasize enough that, technically, a custom post type — as in the thing you create using the
register_post_type() function — is merely the foundational component of what I think of (and what I recommend you think of) as a “custom content module”. In fact, registering a custom post type is probably the simplest and easiest part of creating a custom content module.
Custom Content Module Defined
I define a custom content module as consisting of these components:
- the registered custom post type (required, duh)
- custom fields (technically optional but practically required)
- custom taxonomy/ies (optional)
- custom templates for displaying custom content on the front end (required)
I say that custom fields are practically required though technically optional because without them, a custom post type is nothing more than a post or a page (depending on what you specified when registering it).
(Yes, I suppose you could create a new post type without custom fields for content you want to keep separate from your default blog. But there are other ways to achieve this kind of segmentation, like with standard categories and post tags. Anyway, if you disagree with me, I certainly welcome your comments.)
What I’m Talking About in this Series
The types of custom content I’ll be talking about are similar to the examples from the first post in this series:
- Books you’ve authored (or read)
- Staff directory
- Favorite movies
- Frequently Asked Questions
- Board of Directors
In the next post in this series, we’ll look at the code for registering a basic custom post type for a book. I’ll show you a “verbose” version (about 50 lines of code) as well as an alternate shorter version that takes advantage of the defaults built into the
register_post_type() function. I’ll explain some of the key parameters of the function and, finally, I will show you how you can generate the code using GenerateWP, a popular online code generator.
If you haven’t already done so, check out and bookmark the WordPress codex documentation for register_post_type().