You might find it hard to believe, but for an experienced WordPress developer trying to see something from a new WordPress user’s perspective is almost as difficult as it is for that user to develop a theme or a plugin. Still, dropping your standard hat and putting a different one on every now and then is rarely a bad thing. So let’s take a look at one of WordPress’ most important features – post types, focusing more on the WHYs of using custom post types than the HOWs.
What Are Post Types?
WordPress stores all of its posts into one database table called wp_posts. That includes all of your default post types (posts, pages, navigation menu items, attachments and revisions) and any other post types registered by your themes and plugins. Latter ones are known as Custom Post Types, indicating that when you install a new WordPress site they don’t exist.
Custom post types can be used for anything and basically they’re just posts that have one value that tells WordPress which post type they belong to. This of this as nations – they were made up to keep us apart, even though deep down we’re all the same. Luckily, posts and pages will never go to war with navigation menu items.
Why You Should Use Custom Post Types
A few years ago WordPress started shifting away from a blogging platform and towards CMS. This allowed users to install plugins and themes* that registered custom post types and separated content in more logical ways. Sure, you still can use standard posts or pages to display your latest portfolio projects, events or testimonials but it doesn’t make too much sense to do it that way.
A better way is to use custom post type because this way you can have a separate section of your WordPress dashboard for portfolio, event management or testimonials. You don’t have to go through hundreds or thousands of posts to find your portfolio projects if you can have them all listed in a separate dashboard screen.
*Themes should never handle custom post types. Unfortunately, finding a commercial theme that doesn’t do this seems more difficult than winning the lottery. Need convincing? You can read more about why themes shouldn’t handle custom post types or what happens when you deactivate a theme that does.
Using Custom Post Types the Right Way
When it comes to registering custom post types there really is only one good way to do it – using a plugin. Let a theme do it, decide to change how your website looks, replace the theme and they’re gone. Use a plugin and you won’t have this problem.
Now that you know you will, and more importantly why you will use a plugin there’s two ways to do it. You could look for a plugin that handles specific functionality you need. For example, if you need to add e-commerce to your site, you might want to take a look at WooCommerce. Such a focused plugin can do most of the work for you and the only thing you might need to do is find a theme that supports your plugin (not easy, unless it’s a wildly popular plugin like WooCommerce) or tweak any other theme so it displays custom post types registered by the plugin the way you want them.
If you’d just like to use a custom post type so your projects/events/testimonials don’t mix with standard posts and pages you can use a plugin like Custom Post Type UI or GD Custom Posts And Taxonomies Tools to register your own custom post types. They will look exactly like standard posts but having everything in your dashboard organized is worth the trouble. Of course, it is possible to adjust your theme so it displays custom post types the way you want them, but it will take some PHP and CSS skills or hiring a developer to do it.
The Issue With Custom Post Types
They are great and I can’t remember last time I saw a website without them, but one thing lacking is any sort of standardization. A plugin can register my_plugin_custom_post_type, another one can register some_other_custom_post_type, then there’s the theme that registers five more custom post types, even though it shouldn’t.
This is both good and bad. Good, because there are no constraints to how developers approach custom post types, leading to creative solutions. Bad, because there are no constraints to how developers approach custom post types, letting each one do it his way, sometimes forcing WordPress users to figure out many ways to skin a cat (English language is weird), when all they need is one.
The way I see it, best solution to this problem is having more custom post type WordPress plugins become a standard, like WooCommerce or Contact Form 7. Ever since WooCommerce became so widely accepted you don’t see too many plugins trying to handle “products” post type. I’m sure some day we’ll have such plugins for portfolio projects, events and pretty much anything else, forcing theme developers to work on making sure their themes work WITH custom post type plugins, not compete against them.
Featured image credits: Flickr