Your cart is currently empty!
Custom Post Types in WordPress

If you’ve ever wondered how to add content that doesn’t fit the usual mold of a post or page on your WordPress site, then custom post types might be just what you need.
In this post, we’ll walk through what custom post types are, why you might want to use them, and how to create and display them on your website.
What Are Custom Post Types?
By default, WordPress stores your content as posts, pages, and taxonomies (like categories and tags). Custom post types allow you to add a new kind of content that is tailored to your needs.
For example, if you’re a photographer, you might create a “Portfolio” post type to showcase your work. Other examples include custom types for books, reviews, team members, recipes, or even mountains for a hiking website.
Why Use Custom Post Types?
Custom post types help you organize and display content in ways that standard posts and pages might not support.
For example, consider an e-commerce site using WooCommerce: products are stored as custom post types, and product categories are managed through custom taxonomies.
This makes it easier to manage a large amount of specialized content and offers more flexibility in design and functionality.
Creating a Custom Post Type
There are two main approaches to creating a custom post type:
- Coding It Yourself: If you’re comfortable with coding, you can add the necessary code directly to your theme or a plugin.
- Using a Plugin:
If you’re not a developer, plugins like Custom Post Type UI (CPT UI) and Advanced Custom Fields (ACF) make the process straightforward.
For this example, we’ll use the Custom Post Type UI plugin. Here’s how you can set it up for a hiking website that lists mountains:
- Install and Activate CPT UI: Once installed, a new menu item will appear in your dashboard.
- Add/Edit Post Types: Select the “Add/Edit Post Types” option.
- Name your post type by setting a slug (for example,
mountain
), and provide both singular and plural labels (e.g., “Mountain” and “Mountains”). - You’ll see many label options—use the auto-populate feature to speed things up, and adjust any labels as needed.
- Name your post type by setting a slug (for example,
- Adjust Settings:
- Decide if your post type should be public, searchable, and whether it should appear in navigation menus.
- Change the “has archive” setting to true if you want an archive page for your mountains.
- Uncheck the default taxonomies if you plan to set up custom ones.
- Save Your Settings: Once done, your new custom post type will appear in your dashboard menu alongside posts and pages.
Adding Custom Taxonomies
Custom taxonomies help you classify and organize your custom post type entries. For our hiking website, we can add two taxonomies: Height and Climb Rating.
- Add/Edit Taxonomies: Select “Add/Edit Taxonomies” from the dashboard.
- Set Up Your Taxonomies:
- For the Height taxonomy, use a slug like
height
and set the labels (singular: “Height”, plural: “Heights”). - Choose the mountain post type for this taxonomy.
- Enable hierarchical settings if you want a list-like structure and allow quick or bulk edits.
- For the Height taxonomy, use a slug like
- Repeat for Climb Rating: Follow the same steps to create the Climb Rating taxonomy (for example, with labels “Beginner”, “Intermediate”, “Advanced”).
- Link Taxonomies to Your Post Type: Go back to your custom post type settings, check the boxes for your new taxonomies, and save your changes.
Creating Custom Post Type Entries
Now that you’ve set up your custom post type and taxonomies, you can start adding entries. For example:
- Create a new “Mountain” entry, add your content, assign it to a height category (like “less than 3000 feet”), and select the appropriate climb rating (such as “Beginner”).
- Include a featured image and an excerpt to give visitors a preview of the content.
- Repeat this process for additional entries (e.g., “Second Mountain” and “Third Mountain”).
Displaying Your Custom Post Type on Your Website
To showcase your custom post type entries on your website, follow these steps:
- Create an Archive Page:
- Add a new page (for example, name it “Mountains”).
- Change the page’s slug to match your custom post type slug (in this case,
mountain
).
- Add the Page to Your Navigation Menu:
- Use the Site Editor to access your Navigation block.
- Add the “Mountains” page to your menu.
- Add Placeholder Menu Items for Taxonomies:
- If you want to display your taxonomy classifications (like Height or Climb Rating) as sub-menu items, add them as placeholders. You can do this by setting the menu item URL to “##” so that they are not clickable.
- Then, add the specific taxonomy classifications (such as “less than 3000 feet” or “Intermediate”) as sub-menu items under these placeholders.
When you view your site, clicking on “Mountains” should display all your custom entries, and selecting a taxonomy will filter the content accordingly.
Custom Templates for Your Post Types
WordPress uses templates to control how content is displayed. While your custom post type archive and single entries may use the default “All Archives” or “Single” template, you can customize these if you want a unique look.
- Access the Site Editor:
- Navigate to “Manage All Templates.”
- Create New Templates:
- Choose to add a new template for your custom post type archive (e.g., Archive Mountain Template) or for single mountain entries.
- Customize the layout, design, and content elements as needed.
This allows you to fine-tune the display of your custom post type content and match it to the overall design of your website.
Conclusion
Custom post types are a powerful feature in WordPress that lets you tailor your site’s content to your specific needs.
Whether you’re building a portfolio, a product catalog, or a hiking site that showcases mountains with unique taxonomies like height and climb rating, custom post types offer the flexibility to do so.
By using plugins like CPT UI, you can set up custom post types and taxonomies without writing code, and easily display them on your site through custom pages and templates.
For more tips and in-depth tutorials on WordPress templates and customizations, check out other sessions on learn.wordpress.org.
Happy customizing!
Questions that may arise
What is a custom post type in WordPress?
A custom post type is a way to create and manage content that doesn’t fit into the default post or page formats. It allows you to organize your website content in specialized ways, such as portfolios, products, or even mountains for a hiking site.
Why should I use a custom post type?
Using a custom post type helps structure and display content more effectively for specific needs. It provides flexibility in managing different content formats, making it ideal for sites requiring special categories, such as e-commerce products or creative portfolios.
How can I create a custom post type without coding?
You can use plugins like Custom Post Type UI (CPT UI) and Advanced Custom Fields (ACF) to easily generate custom post types. These plugins provide user-friendly interfaces that allow you to set up and manage custom post types without writing any code.
Which plugin is recommended for creating custom post types?
The Custom Post Type UI (CPT UI) plugin is highly recommended as it simplifies the creation and management of custom post types. It allows you to define labels, settings, and taxonomies quickly and efficiently.
How do I add custom taxonomies to a custom post type?
Custom taxonomies can be added using the same plugin used to create the custom post type, such as CPT UI. You simply configure the taxonomies (for example, Height and Difficulty Level) and link them to your custom post type, making it easier to organize and filter content effectively.
Can I customize the templates for my custom post type?
Yes, you can create or modify templates specifically for your custom post type. Using the WordPress Site Editor, you can design archive and single entry templates that control the layout and design of your custom content, making your site unique.
What happens to my custom post type if I change my theme?
It is recommended to place custom post types in a plugin rather than directly in the theme. This ensures that your content remains intact and portable even if you change the theme, keeping your custom post type data separate from theme files.