WordPress GuidePost → 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:

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:

Step-by-step: using Custom Post Type UI

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

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:

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:

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.

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

A custom post type is a special type of content that organizes information separately from standard posts and pages. It creates a new section in your dashboard with its own fields, taxonomies, and templates.

WordPress stores CPTs in the wp_posts table with a unique post_type identifier. Custom fields and metadata live in wp_postmeta, just like regular posts.

You create custom templates by adding files named single-{post_type}.php and archive-{post_type}.php in your theme. Block themes let you build these templates visually in the Site Editor.

Capabilities control who can create, edit, publish, or delete CPT items. You define them in register_post_type or assign them with a role plugin. This lets you create permissions tailored to your content and team structure.

Ready to get started?

Get the fastest, most secure WordPress.org hosting on the market.

Trust us to help you choose the ideal hosting solution

Loading form…