◦ Comprehensive security
◦ 24/7 support
WordPress Guide → Post → Custom Types
How to create WordPress custom post types
WordPress posts and pages work fine for blogs and basic websites. But when your site needs to display content like portfolios, testimonials, events, or products, posts and pages fall short.
That’s where custom post types (CPTs) come in. They let you structure and manage different kinds of content, each with its own layout, features, and admin screens. Whether you want a lightweight solution or full developer control, there’s a method that fits your workflow.
Get fast, reliable hosting for WordPress
Power your site with the industry’s fastest, most optimized WordPress hosting
What custom post types are and why they matter
A custom post type (CPT) is a special content type in WordPress that lets you create and manage structured content like events, portfolios, or products separately from regular posts and pages.
Custom post types expand WordPress beyond standard Posts and Pages, and act like dedicated buckets for content that doesn’t belong in your regular blog feed. You might use one for real estate listings, testimonials, products, or anything else that needs specialized fields and its own editing screen.
A CPT keeps that content organized and creates a dedicated interface in the dashboard, so you can manage it cleanly without mixing it with posts. You also get more design freedom because CPTs support their own page templates, custom fields, and taxonomies.
When you should use a custom post type
Some content needs structure that regular posts don’t offer. CPTs solve that by giving you fields, taxonomies, and layouts tailored to a specific purpose.
You might create a CPT for:
- Events with dates, venues, and ticket links.
- Portfolios with project images and descriptions.
- Team members with bios, roles, and headshots.
- Recipes with ingredients and nutrition fields.
- Directory listings with contact details and categories.
If you find yourself adding the same custom fields repeatedly or trying to force content into categories that don’t make sense, a CPT usually makes your life easier.
How custom post types work behind the scenes
WordPress stores CPTs in the same database table as posts, but each one has a different post_type value. This lets WordPress treat the content differently when displaying archive pages, editing screens, and custom loops.
CPTs also support their own taxonomies, custom fields, menu icons, and admin columns. Once you register a CPT, the dashboard gains a new menu item with a full editing interface.
Method 1: Create a custom post type with a plugin
Many beginners prefer plugins because they simplify the setup and let you create CPTs without touching code. These tools generate everything needed for WordPress to recognize and display your new post type.
Popular plugin options
These plugins provide simple forms where you choose labels, slugs, and supported features:
- Custom Post Type UI gives you a clean interface to create post types and taxonomies.
- Advanced Custom Fields lets you add custom fields and layouts to your CPTs.
Step-by-step: using Custom Post Type UI
- Install and activate Custom Post Type UI from the WordPress Plugin Directory.
- Open the “CPT UI” tab in the dashboard and click “Add/Edit Post Types.”
- Enter a slug like portfolio, event, or recipe. The slug should stay lowercase and avoid spaces.
- Fill in the labels that control how the CPT appears in menus and admin screens.
- Select features you want to support, such as title, editor, featured image, custom fields, or excerpts.
- Assign taxonomies if you want categories or tags for your CPT. You can create new ones in the plugin interface.
- Save your settings, then visit the dashboard to confirm your new CPT now appears in the main menu.
Method 2: Create a custom post type manually (register_post_type)
Manual registration gives you full control over how your CPT behaves. You write one function in PHP, and WordPress handles the rest. Beginners can follow this method too, as long as they move slowly and keep a backup.
Step-by-step: register a custom post type in functions.php
- Open your theme’s functions.php file or your child theme’s functions file so your CPT remains safe during theme updates.
- Add a basic register_post_type function. This tells WordPress the CPT name, labels, rewrite behavior, and supported features.
- Choose which editor features you want to use, like the editor, title, thumbnails, custom fields, or revisions.
- Set rewrite rules so your CPT uses clean URLs like /portfolio/project-name/.
- Save the file, then go to Settings → Permalinks and click Save to flush rewrite rules. This ensures your new URLs work correctly.
Example code snippet
function mysite_register_portfolio() {
$args = array(
‘label’ => ‘Portfolio’,
‘public’ => true,
‘menu_icon’ => ‘dashicons-portfolio’,
‘supports’ => array(‘title’,’editor’,’thumbnail’),
‘has_archive’ => true,
‘rewrite’ => array(‘slug’ => ‘portfolio’),
);
register_post_type(‘portfolio’, $args);
}
add_action(‘init’, ‘mysite_register_portfolio’);
Why you might prefer the manual method
The manual method gives developers full flexibility. You can version-control everything, customize capabilities, and fine-tune taxonomies in ways that plugins don’t always allow. It also removes plugin overhead, which improves performance.The manual method gives developers full flexibility. You can version-control everything, customize capabilities, and fine-tune taxonomies in ways that plugins don’t always allow. It also removes plugin overhead, which improves performance.
How to create custom taxonomies for your CPT
Custom taxonomies help you group your CPT content. You can make hierarchical ones like categories or flat ones like tags.
When should you use custom taxonomies? When your content needs unique filters. A recipe site might use “Cuisine” and “Difficulty.” A real estate directory might use “Property Type” or “Neighborhood.”
You can create taxonomies with Custom Post Type UI, or register them manually with register_taxonomy in your functions file.
How to build a custom post type template
Templates give your CPTs unique layouts on the front end. WordPress checks for template names that match your CPT slug.
The core templates are:
- single-{post_type}.php for individual items.
- archive-{post_type}.php for listing all items.
- In block themes, you can build these templates using Full Site Editing. Just open Appearance → Editor, create a new Template, and choose your CPT from the list.
Using plugins for CPT templates
If you prefer to build layouts visually, plugins help you skip the code. You can use Block Visibility or Custom Layouts – Post + Product Grids Made Easy to design grids, cards, and dynamic loops for your custom content.
How to display your custom post type on the front end
Once your CPT exists, you can display it in multiple ways:
- Your CPT’s archive will usually appear at /{slug}/, unless you change the rewrite rules.
- You can use the Query Loop block to display CPT items anywhere on your site.
- You can use plugins like Custom Layouts to build dynamic grids without PHP.
If you prefer code, you can write a custom WP Query loop to output CPT entries in a theme file or shortcode.
Custom capabilities and roles for your CPT
Capabilities control who can edit, delete, or publish your CPT content. This becomes important for teams or membership sites.
You can assign capabilities directly inside register_post_type by customizing the capability array.
If you prefer a plugin-based approach, tools like Members let you assign capabilities through easy dashboards so you can create roles like “Recipe Editor” or “Portfolio Manager.”
Common mistakes to avoid when creating CPTs
Beginners often run into small issues that slow everything down. You avoid most problems if you plan ahead.
- Using reserved names such as post or page can break your site. Use unique slugs like portfolio, event, or listing.
- Forgetting to flush permalinks means your CPT pages return 404 errors. Visit Settings → Permalinks and click Save.
- Adding CPTs inside a theme makes them disappear when you change themes. Create them in a plugin, even a simple custom one.
- Not registering taxonomies early enough leads to duplicate work later. Plan your categories and filters before creating fields.
- Adding too many custom fields makes the CPT difficult to manage. Keep each content type simple and structured.
How hosting performance impacts custom post types
CPT-heavy sites depend on strong hosting, because they often run more database queries and use more dynamic templates. A directory with thousands of listings or an ecommerce catalog with large product data needs more CPU, faster PHP execution, and better caching.
A solid hosting environment improves search filters, archive loading, and template rendering, especially when CPTs contain images or large metadata. Fast hosting helps you avoid slow dashboard performance and lets editors update CPT entries smoothly.
Custom post type FAQs
Next steps for creating WordPress custom post types
Custom post types help you organize your content, create better admin workflows, and build more dynamic WordPress sites. Once you understand how they work, you can start using WordPress as a full-featured content management system.
Start with a plugin like CPT UI if you’re still experimenting. If you’re building custom themes or client sites, move your post types into a plugin and start working with custom templates and fields.
Ready to upgrade your WordPress experience? Professional hosting improves speeds, security, and reliability for a website and a brand that people find engaging and trustworthy.
Don’t want to deal with server management and maintenance? Our fully managed hosting for WordPress is the best in the industry. Our team are not only server IT experts, but WordPress hosting experts as well. Your server couldn’t be in better hands.
Click through below to explore all of our hosting for WordPress options, or chat with a WordPress expert right now to get answers and advice.
Additional resources
What is WordPress? →
A complete beginner’s guide to WordPress.org
WordPress post formats (and which pokemon they would be) →
Learn about different WordPress post formats and how they help structure and style your content effectively.
Beginner’s Guide to WordPress themes →
Learn how they work, what to look for, how to choose, and more