Vincent Zhang

Engineering, Design & Productivity

When to use custom post types in WordPress

Foreword

This is the part I of my How to organize stuff in WordPress series. Hold tight.

I’m frequently amazed by the different ways you can organize stuff in WordPress. To start with the basics, you got your posts and pages. Then you got categories and tags that you can put on them. Venture beyond that, are the custom ones: custom post types, custom taxonomies, custom fields.

This article will focus on custom post types. I’ll keep this as brief as possible, since there are millions of tutorials and articles online regarding this topic already.

We’re only going to talk about a few things here: first, a brief definition; then talk about when to use it; and to top it off, I’ll explain why is it so confusing to understand. Let’s go.

What are custom post types

To explain, we need to first define what is a post type: it’s a type of content that’s represented as a sidebar item on your WordPress Dashboard Screen. You can see at least three: Posts, Media (attachments) and Pages.

Therefore, custom post type is a special kind of post type that you can, well, customize yourself.

When to use custom post types

You should only create a custom post type if you want to create a new, non-post type of content that doesn’t show up among the post queries, such as the main blogroll and the default post archives.

For example, products on an e-commerce site, or projects on a personal portfolio site are great examples.

Can you make these with pages? Of course you can. It probably makes more sense to use pages when you only have a small number of them, because the initial cost of setting up a custom post type is high. But if you have more, or have the desire to create more of this type of content, then it makes sense to use custom post types.

Why are custom post types so confusing

I struggled with this at lot. In the last five years, I have looked up its definition and usages at least a dozen times. And without fail, I forgot about it soon after.

I eventually realized the reason custom post types seemed so confusing and didn’t stick in my mind was because of a deeper problem within WordPress.

Custom post type is a confusing term because in WordPress, the word post carries double meanings:

First is post in the common sense: a blog post, with commonly expected metadata such as time, author and category.

Then we have post in the programmatic sense: buried deep in WordPress’s internal logic, a post is any type of content entry. This includes all default post types (post_type in the database): blog posts, pages, revisions, attachments, navigational menu items, custom CSS and changesets (the last two can only be generated by the Customizer). This is reflected in the tables that WordPress database dictates: wp_posts and wp_postmeta. In reality, a more appropriate and less confusing term for this case would be entry, but history happened and here we are.

Therefore, what helped me to establish a better mental model is to modify the phrase: instead of custom post type, let’s think of it as custom entry type. Isn’t that much clearer?

Footnote: for a more detailed explanation on custom post types, I found this article really helpful.

Leave a comment