When planning website development, one important consideration is whether or not your WordPress site needs a custom post type. In this article, we’ll go over what a custom post type is and how to decide whether your WordPress website needs one. We’ll also check out some examples of custom post types and start understanding what it takes to create them.
What is a WordPress Custom Post Type?
WordPress comes with default post types. When you’re working in the WordPress dashboard, the two most visible post types are posts and pages.
Posts are usually arranged within archives and organized by category, while pages are used for static content like the homepage or About Us page. There are other default post types, such as attachments, revisions, and navigation menus.
Custom post types are commonly used when you need to create a new content type that extends the functionality of the default posts post type. A post within a custom post type is similar to a default post but can have a custom layout, custom fields, custom taxonomy, and its own archive pages. If that sounds like technical mumbo-jumbo, hold on because all of these terms will be explored and illustrated in this article.
Creating a custom post type allows you to take control of your content. You can create an editing experience structured and organized around the specific content you want to publish.
Questions to Ask Yourself
When considering whether your WordPress website will need a custom post type, there are four questions that you can ask yourself. A custom post type is a good idea if you answer “yes” to one or more of these. All four will work together to create a comprehensive custom post type.
Question 1: Will I be creating many posts that need a special layout?
A custom post type will help you create a collection of posts with a standardized layout. You can structure your post type to show your custom content in the same place each time. This helps you develop your content and creates a consistent user experience for your readers.
Couldn’t I do this with a block pattern?
Yes, you could!
With the new block features in WordPress, you could create a block pattern to save a reusable block layout. It takes minimal development work, and once it’s been set up, you could use your block pattern every time you create a post that needs that layout. However, WordPress would not automatically generate an archive of these posts that is separate from the rest.
Question 2: Will I be creating lots of posts that will need their own custom fields?
Custom fields are usually assigned to custom post types, allowing you to create content specific to that post type. For example, let’s consider a custom post type for books. In this custom post type, you could define custom fields for things like the author name, publisher, publication date, ISBN, language, description, format, rating, and retail links.
When you combine these custom fields with a custom layout, you can create a consistent editing and reading experience for all of the posts within this custom post type.
Couldn’t I create these fields for all posts, and just not use them on the posts that don’t need them?
You could, but that would be a confusing mess!
You would have to ignore those fields on any post type that they don’t apply to. You would also need to consider whether posts output unnecessary markup on your web pages, which could create issues for SEO and accessibility.
Question 3: Will I be creating many posts that need their own archive page?
Custom post types come with their own archive pages. Default posts automatically get an archive, which you’re already familiar with. This includes the directory of all your posts (such as /blog/ or whatever you have defined) and the category and tag pages.
When you use a custom post type, any time you publish a new post, that post will be automatically added to the archives for the post type. You can link to the archive in your site’s navigation to direct users to all the posts within the custom post type.
Couldn’t I just make a page and link to the posts that I want to include?
You could, but that’s a lot of manual work.
Every time you publish a post, you must remember to add it to the page. If you forget, the page will become outdated and will be missing posts that should be there.
Question 4: Will I be creating lots of posts that need their own special set of categories?
With custom post types, you can create custom taxonomies. These are useful if you want to define special categories for your custom post type.
You can keep them separate from the default posts so that they can be easily found by your readers. For example, if you had a custom post type for books, you could create categories for each genre.
Couldn’t I just use the regular categories and make a category for book posts?
Yes, you could. If all you’re doing is writing default posts on a certain topic, you can make a category for that topic.
You can even use the default categories with a custom post type. However, if you do that, you will be including posts from your custom post type in the standard archives, so they will be mixed in with your default posts. That is completely fine to do if you do not need them separated.
Examples of Custom Post Types
So far, we’ve reviewed some fairly technical considerations about custom post types. Now we’ll take a look at five real-world examples of custom post types that will help us understand what custom post types can be used for.
Each example includes a basic wireframe-style graphic that illustrates the concept of the post type as seen on the front end of the website. Orange boxes indicate elements that come built into the post from WordPress, like the title, featured image, and main content area. Green boxes indicate custom fields.
Basic event information could be handled with a custom post type. Each post could have custom fields related to events and a specific layout for the data to be displayed on the front end of the website. An archive for event posts would let the user browse all upcoming events.
Custom fields for an events custom post type could include:
- Start Date
- Start Time
- End Date
- End Time
- Sponsor Logos
Events that require advanced features like registration and payments might need to be set up in WordPress with a plugin such as The Events Calendar. That plugin will create a custom post type as part of its installation process.
There are many recipe blogs online, and a custom post type would go a long way towards helping a chef organize their website.
Custom fields for a recipes custom post type could include:
- Prep Time
- Cook Time
- Nutrition Facts
- Image Gallery
- Cuisine Type
A custom taxonomy would be ideal for a recipe post type because it would allow you to create categories based on the type of cuisine, how long the recipe takes to make, or dietary restrictions.
A site that posts content about books would benefit from a books custom post type. It would help organize the metadata about each book and provide an archive of books.
Custom fields for a books custom post type could include:
- Retail Links
- Other Books You Might Like
Avid readers are always interested in finding more books. This custom post type could create associations between authors or genres to connect books together and make reading suggestions.
Directory of People or Organizations
Companies that display a directory of employees often have a “team” page with photos and bios for each team member.
Custom fields for a team custom post type could include:
- Contact Info
- Social Media Links
The individual’s name and bio would be included in the standard fields. The title of the post would be used for the name, and the regular content editor would be used for the bio.
Another similar use case for a post type like this would be a directory of organizations. These might be member organizations, contributors to your service, or client profiles.
Designers, freelance web developers, consultants, small businesses, and many other professionals create portfolios to impress potential clients. A custom post type would help organize portfolio posts so that your work examples look polished and professional.
Custom fields for a portfolio custom post type could include:
- Image Gallery
- Project Type
- Client Name
- Technology or Materials Used
- Call to Action
The call-to-action might be made up of a heading, paragraph text, and a button that invites readers to contact you.
A Custom Post Type Illustrated
Now that we understand what custom post types are typically used for, let’s flesh out one of our examples a little more.
Using the example of the books custom post type, we can add a few more details to its custom fields. Additionally, we can consider the layout for single posts and archive pages.
This wireframe for the single post expands on the basic example above and shows a layout that includes a brief description, a full description, and a publication date.
Next is an idea of what the archive could look like. It uses these elements:
- Breadcrumbs at the top of the page would let the user navigate up a level to see all genres
- A heading for the category name (such as Fiction, Fantasy, Travel, etc.)
- A couple of paragraphs of text that describe the genre category
- A grid of book covers, each of which links to the post for that book
- Pagination links at the bottom of the page
Since this is a category page for a genre, this would be a custom taxonomy defined for the post type, allowing the site administrator to categorize books into genres.
Creating a Custom Post Type
This article focuses on understanding custom post types and whether your WordPress website needs one. But while we’re at it, let’s take a quick look at how you would create a custom post type if you decide you need one. This is not an in-depth technical tutorial, but an overview of the process.
There are two pieces to creating most custom post types: making the post type itself and defining custom fields. There are different methods for this, with varying levels of programming needed, but custom development work is necessary.
Make the Custom Post Type and Taxonomy
The most popular option for creating a custom post type is the Custom Post Type UI plugin, which provides an easy interface for creating custom post types and taxonomies in WordPress.
Using this plugin to create a “books” custom post type would look like this:
We can also use Custom Post Type UI to create our “genres” taxonomy and attach it to our custom post type:
Add Custom Fields
The next step is to define custom fields for your post type. In our books example, fields include author name, publisher, rating, language, and retail links.
The industry-standard method for creating custom fields is by using the plugin Advanced Custom Fields. It has a free version and a pro version with extra features.
A field group for our books custom post type would look something like this:
Defining your custom fields is only part of the procedure. After you have set up your fields within the plugin, it’s also necessary to use code to tell WordPress how to use these fields with your custom post type.
Get started with the documentation on displaying values in your theme. The details are outside the scope of this article, but there are many resources online that provide full tutorials on creating custom post types.
WordPress is a customizable publishing platform that allows you to create custom post types, define your design and layout for posts and archive pages, and publish exactly the type of content you want to show the world.
With the information in this article, you should now understand what custom post types are, what they can be used for, and whether your WordPress website could benefit from them.
If you need help developing a custom post type, contact us! We’d love to hear about what you’re creating.