Plugin Development

WordPress Custom Post Types: When and How to Use Them

Custom post types let you organize content beyond posts and pages. Here's when CPTs are the right tool, how to register them correctly, and what to watch out for.

W
Wordimatic Team
· October 20, 2026 · 8 min read

WordPress ships with two built-in content types: posts and pages. For a blog, this is sufficient. For a site that manages products, case studies, team members, events, testimonials, or any other structured content that isn’t quite a post and isn’t quite a page, custom post types (CPTs) provide the right structure.

Understanding when to use CPTs versus other approaches — and how to implement them correctly — is foundational to building well-structured WordPress sites.

What custom post types are for

A custom post type is a content collection with its own admin UI, its own URL structure, and its own set of fields and taxonomies. It behaves like posts or pages but represents a distinct content type in your site’s information architecture.

Examples of content that commonly warrants a CPT:

  • Products in a non-WooCommerce catalog
  • Case studies with structured fields (client, industry, results)
  • Team members with biographical data and social links
  • Events with date, location, and registration fields
  • Testimonials with author, company, and rating fields
  • Documentation articles in a knowledge base, separate from blog posts

The alternative to a CPT for each of these is shoehorning the content into posts or pages with categories to distinguish them. This works at small scale and fails at larger scale: the admin UI becomes cluttered, queries that need to target only “events” become more complex, and URL structures don’t reflect content semantics.

When NOT to use a custom post type

Not everything that’s different from a blog post needs its own CPT. Overusing CPTs creates complexity without benefit.

Use a taxonomy instead. If you have a single content type that needs to be categorized in a new way, adding a custom taxonomy to posts is often the right answer. A “project type” taxonomy on posts is simpler than a “projects” CPT when the content structure is the same as a post.

Use custom fields instead. If posts need additional data fields (a featured quote, a subtitle, a secondary image), custom fields via Advanced Custom Fields or similar are the right tool. A CPT is for when the content type is structurally different enough to warrant its own admin section and URL structure.

Use posts with a category. A “news” category on posts is appropriate when news articles have the same structure as other posts and you just want to filter them. A news CPT only makes sense if news articles have distinct fields, a distinct URL structure, or distinct administrative workflows.

The question to ask: does this content type genuinely behave differently from posts, or does it just belong to a different category?

Registering a custom post type

CPTs are registered on the init action using register_post_type(). This belongs in a plugin (even a simple site-specific plugin), not in functions.php — CPT registration in a theme means you lose your content if the theme changes.

Basic registration example:

add_action( 'init', 'register_case_studies_cpt' );

function register_case_studies_cpt() {
    $labels = [
        'name'               => 'Case Studies',
        'singular_name'      => 'Case Study',
        'add_new_item'       => 'Add New Case Study',
        'edit_item'          => 'Edit Case Study',
        'view_item'          => 'View Case Study',
        'search_items'       => 'Search Case Studies',
        'not_found'          => 'No case studies found.',
        'menu_name'          => 'Case Studies',
    ];

    $args = [
        'labels'             => $labels,
        'public'             => true,
        'has_archive'        => true,
        'rewrite'            => [ 'slug' => 'case-studies' ],
        'supports'           => [ 'title', 'editor', 'thumbnail', 'excerpt' ],
        'menu_icon'          => 'dashicons-portfolio',
        'show_in_rest'       => true, // Required for Gutenberg support
    ];

    register_post_type( 'case_study', $args );
}

Key arguments to understand:

public: Makes the CPT visible in the admin and publicly queryable. Set to false for internal data types that shouldn’t be browsable.

has_archive: Creates an archive page at the CPT’s slug (e.g., /case-studies/). Required if you want a listing page.

rewrite: Controls the URL slug. Keep it readable and aligned with how you’ll reference the content.

supports: Which meta boxes appear in the editor (title, content editor, featured image, excerpt, comments, revisions, custom fields).

show_in_rest: Must be true for the CPT to work with the Gutenberg block editor. If omitted or false, editing this CPT uses the classic editor.

After registering a new CPT, visit Settings → Permalinks and click Save to flush the rewrite rules. Until you do this, CPT URLs return 404.

Associating taxonomies

CPTs can use WordPress’s built-in taxonomies (category, tag) or custom taxonomies. Register a custom taxonomy and associate it with your CPT:

add_action( 'init', 'register_case_study_industry_taxonomy' );

function register_case_study_industry_taxonomy() {
    register_taxonomy( 'industry', 'case_study', [
        'label'        => 'Industries',
        'hierarchical' => true, // true = categories, false = tags
        'rewrite'      => [ 'slug' => 'industry' ],
        'show_in_rest' => true,
    ] );
}

Register taxonomies in the same init hook as the CPT (or in a separate callback at the same priority) to ensure both are registered when WordPress flushes rewrite rules.

Querying custom post types

WordPress queries return posts by default. To query a CPT, specify the post type:

$case_studies = new WP_Query( [
    'post_type'      => 'case_study',
    'posts_per_page' => 6,
    'tax_query'      => [
        [
            'taxonomy' => 'industry',
            'field'    => 'slug',
            'terms'    => 'technology',
        ],
    ],
] );

The main WordPress loop on archive pages uses the correct CPT automatically when the CPT has has_archive set and a template is configured. For custom queries embedded in templates, use WP_Query as above.

Templates for custom post types

WordPress’s template hierarchy supports CPT-specific templates. For a CPT registered as case_study:

  • single-case_study.php — single item template
  • archive-case_study.php — archive listing template
  • taxonomy-industry.php — taxonomy archive template

Create these in your theme or child theme. If they don’t exist, WordPress falls back to single.php, archive.php, and taxonomy.php respectively.

For Gutenberg-based themes, CPT templates can also be defined in the templates/ directory as block templates (JSON format).

Gutenberg and show_in_rest

The Gutenberg block editor requires show_in_rest: true on the CPT. Without this, the CPT falls back to the classic TinyMCE editor, which may or may not be what you want.

If you’re using Advanced Custom Fields or similar for CPT-specific fields, confirm ACF’s field groups are assigned to the correct CPT and are configured for compatibility with whichever editor you’re using.

Implications for plugin and theme changes

CPTs registered in a plugin are database entries — the actual posts exist in wp_posts regardless of whether the plugin is active. If you deactivate the registering plugin, the posts still exist in the database but the CPT is no longer registered, so they become invisible in wp-admin and return 404 on the frontend.

This is the correct behavior, and it’s why CPT registration belongs in a plugin that you intentionally manage rather than in a theme that might get swapped. If you’re using CPTs for business-critical content, treat the registering plugin as a core dependency — don’t deactivate it casually.

The custom plugin guide covers this scenario: when content structure is central to how the site works, purpose-built code you own is more stable than a third-party CPT plugin that could be abandoned. The WordPress hooks and filters guide explains the init action and hook-based registration pattern used here.

Content architecture built to last
Wordimatic builds custom plugins that include well-structured CPT registration, custom taxonomies, and field definitions — designed for long-term maintainability, not just immediate function. Talk to us about your content requirements.