Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

WordPress Custom Post Types: A Complete Guide

A complete, practical guide to WordPress custom post types: when to use one, how to register it in a plugin, configure supports and URLs, add taxonomies and fields, expose REST API access, design capabilities, and test the finished workflow.
Length12 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A WordPress custom post type (CPT) is a developer-defined content model for information that does not fit ordinary posts or pages. Registering one gives that content its own fields, taxonomies, templates, archive behavior, permissions, and—when enabled—REST API endpoints.

The durable approach is to register the type from a plugin on the init hook, choose only the editor features you need, register taxonomies separately, expose the type to the block editor deliberately, and design capabilities around the people who will create, publish, edit, and read the records.

As an Amazon Associate I earn from qualifying purchases.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a custom post type is—and when you need one

WordPress includes built-in post types such as posts, pages, attachments, revisions, and navigation menus. A custom post type adds another structured content type to that system. It is not merely a category or a visual template: it defines a distinct kind of record with its own editorial behavior and query identity.

Use a CPT when the content has a stable schema and workflow that should remain separate from blog posts or pages. Typical examples include books, events, products, properties, staff profiles, and case studies. A separate type is particularly useful when editors need different fields, a dedicated archive, a different URL pattern, distinct taxonomies, or permissions that do not match the rest of the site.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
  • Choose a CPT when the item is a recurring record with consistent attributes and an identifiable lifecycle.
  • Use ordinary posts when the content is primarily chronological publishing and the existing post fields and taxonomies are sufficient.
  • Use pages when the content is mostly hierarchical, relatively permanent site information that fits the page editor.

A CPT does not automatically create every field your project needs. Registration establishes the content type; supports, taxonomies, post meta, templates, queries, and capabilities complete the implementation.

Plan the content model before writing code

Write down the record’s editorial and technical requirements first. This prevents a common failure mode: registering a type with broad defaults and later discovering that its URLs, permissions, or fields do not match the workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Define the record and its lifecycle

  • What is one record? For example, one event, one property, or one staff profile.
  • Which values are essential, and which are optional?
  • Who drafts, edits, reviews, publishes, and retires records?
  • Should records have public single pages, a public archive, search visibility, or only an authenticated interface?
  • Will another system consume the records through the REST API?

Choose a durable post-type key

The post-type key must be no longer than 20 characters. Use lowercase letters, numbers, dashes, or underscores, and choose a readable, unique name that will not collide with a core type or another plugin. Treat the key, rewrite base, and taxonomy names as long-lived identifiers: changing them after publication can require redirects, data migration, and rewrite-rule flushing.

Decide who owns the definition

Put the registration in a plugin when the content should survive a theme change. A theme-registered type disappears from the administration interface when that theme is switched, even though the underlying data may still exist in the database. A plugin keeps the content model available while the presentation layer changes.

Register the CPT on the init hook

WordPress provides register_post_type() for registration. Call it from a plugin on init, after WordPress has loaded the environment in which post types are registered.

<?php
/**
 * Register the Book post type.
 */
function vg_register_book_post_type() {
    $labels = array(
        'name'          => 'Books',
        'singular_name' => 'Book',
        'add_new_item'  => 'Add New Book',
        'edit_item'     => 'Edit Book',
        'new_item'      => 'New Book',
        'view_item'     => 'View Book',
        'search_items'  => 'Search Books',
    );

    register_post_type(
        'book',
        array(
            'labels'       => $labels,
            'public'       => true,
            'show_ui'      => true,
            'show_in_rest' => true,
            'has_archive'  => true,
            'rewrite'      => array('slug' => 'books'),
            'supports'     => array('title', 'editor', 'thumbnail', 'excerpt', 'author', 'revisions'),
        )
    );
}
add_action('init', 'vg_register_book_post_type');

The example deliberately shows only the core registration decisions. In a production plugin, give the type a complete label set and set visibility, archive, rewrite, supports, capabilities, and REST options to match the model rather than copying defaults blindly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Important registration arguments

  • labels: supplies the names editors see in menus, buttons, searches, and screen headings.
  • public: expresses the intended public visibility and influences related defaults. Confirm the resulting front-end and query behavior rather than assuming one flag answers every visibility question.
  • show_ui: controls whether WordPress provides an administration interface for the type.
  • has_archive: determines whether the type has an archive view. Pair it with an intentional rewrite slug and an archive template.
  • rewrite: defines the URL structure. Keep the base stable after links have been published.
  • supports: lists the editor features this type actually needs.
  • show_in_rest: exposes the type to the block editor and standard REST routes when the rest of the permissions and controller configuration allow it.

Flush rewrite rules only when the structure changes

Registering a type does not by itself guarantee that existing rewrite rules know about its URLs. Flush rewrite rules when the plugin is activated or deactivated, not on every request. Flushing on every page load adds avoidable work and can create operational problems.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
<?php
function vg_activate_books() {
    vg_register_book_post_type();
    flush_rewrite_rules();
}
register_activation_hook(__FILE__, 'vg_activate_books');

function vg_deactivate_books() {
    flush_rewrite_rules();
}
register_deactivation_hook(__FILE__, 'vg_deactivate_books');

If you change a rewrite slug or add an archive after activation, deactivate and reactivate the plugin, or otherwise perform a controlled flush, then test the resulting URLs and redirects.

Choose editor features with the supports array

The supports array controls which core editing features are available for a CPT. Enabling everything can make a screen confusing and can imply a workflow your content does not need.

Support What it provides When it fits
title A title field Records need a human-readable name or headline
editor The main content editor Each record has narrative or formatted body content
thumbnail A featured image Cards, archives, or single views need a primary image
excerpt An editable summary Editors need control over archive or listing descriptions
author An author assignment Ownership, attribution, or author-based queries matter
revisions Revision history Editors need to compare or restore prior versions
comments Comments and discussion settings Readers or collaborators should comment on records
custom-fields Core custom-field UI support Editors need to manage post meta through the supported interface
page-attributes Page-order and parent-style attributes The project needs ordering or hierarchical relationships in the editor
post-formats Post-format support The theme and editorial model explicitly use post formats

For example, a staff profile may need a title, editor, thumbnail, excerpt, and revisions, while an internal record may need a title and custom fields but no public comments. Remove supports that have no editorial purpose.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add taxonomies for classification

Taxonomies classify records; they are not substitutes for every structured field. Register each custom taxonomy with register_taxonomy(), then connect it to the CPT through the post type’s taxonomies argument. The explicit connection helps WordPress recognize the relationship in query-related hooks, while the taxonomy still requires its own registration.

<?php
function vg_register_book_taxonomy() {
    register_taxonomy(
        'book_genre',
        array('book'),
        array(
            'label'        => 'Genres',
            'public'       => true,
            'hierarchical' => true,
            'show_in_rest' => true,
            'rewrite'      => array('slug' => 'book-genre'),
        )
    );
}
add_action('init', 'vg_register_book_taxonomy');

You can also include the taxonomy name in the CPT registration:

'taxonomies' => array('book_genre'),

Hierarchical versus non-hierarchical

Taxonomy style Model Typical use
Hierarchical Terms can have parent and child terms Genres, departments, regions, or other nested classifications
Non-hierarchical Flat, tag-like terms Topics, keywords, or labels that do not need a tree

Give a taxonomy a stable name and rewrite base before editors publish links. Renaming terms or changing hierarchy later can affect archives, internal links, and queries.

Use post meta or registered fields for structured attributes

Attributes such as an ISBN, event date, price, venue, staff role, or property size belong in post meta or a field-management layer rather than in the title or a comma-separated paragraph. Register the meta keys used by your application, validate incoming values, and sanitize them before saving. Keep the data type and expected format consistent so templates and queries can rely on it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Separate classification from attributes: a genre or department is usually a taxonomy term, while a date or numeric measurement is usually a field. Avoid exposing sensitive or internal values merely because they are stored on a publicly queryable record.

Plan field behavior

  • Define whether a field is required, optional, repeatable, or generated.
  • Choose a canonical format for dates, numbers, identifiers, and URLs.
  • Validate values on save and handle autosaves, revisions, and permission checks.
  • Escape values for their output context when rendering HTML, attributes, JavaScript, or URLs.
  • Decide whether the field should be exposed through REST; exposure is an API commitment, not just a convenience.

Expose the CPT to the block editor and REST API

Set show_in_rest => true when editors should use the block editor for the CPT or when an integration needs standard REST endpoints. WordPress uses the standard wp/v2 namespace for core controllers, and registration supports options such as rest_base and controller customization.

'show_in_rest' => true,
'rest_base'     => 'books',

The REST schema describes properties such as the type’s name, slug, labels, description, hierarchy, viewability, and capabilities. Treat that schema and every exposed meta field as a contract: changing names, formats, or permissions can break clients.

Visibility is governed by permissions

Public records are generally readable through public routes when their visibility settings allow it. Private content, internal users, custom post types, and metadata may require authentication or explicit exposure. A route existing does not mean every visitor can read or modify every record.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Check unauthenticated reads separately from authenticated reads.
  • Test draft, pending, private, and published records with the roles that will use them.
  • Expose only the meta fields an integration needs; do not include confidential notes or internal identifiers by accident.
  • Review create, edit, publish, and delete behavior, not just whether a GET request succeeds.

Design capabilities and role access

Permissions are part of the content model. A CPT can use capability_type, an explicit capabilities array, and map_meta_cap to shape authorization. Meta capabilities describe an action on a specific record, while primitive capabilities are the role-level permissions to which those actions are mapped.

Capability category Examples Question to answer
Meta capabilities edit_post, read_post, delete_post May this user perform this action on this particular record?
Primitive capabilities edit_posts, edit_others_posts, publish_posts, read_private_posts What broad capability should a role receive?

When you use the capabilities parameter, complete the capability mapping deliberately. Decide whether authors can edit only their own records or also other authors’ records, who may publish, who may delete, and who may read private items.

Assign capabilities during plugin lifecycle events

Grant the required primitive capabilities to the appropriate roles during plugin activation, and handle role changes during deactivation or an explicit migration. Do not assume that registering a CPT automatically gives an existing role the permissions your workflow needs. Test each role in the administration screens and through the REST API.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Example capability model

An editorial team might allow contributors to create and edit their own drafts, editors to edit anyone’s records and publish them, and a restricted role to read private records without publishing. The exact assignment depends on the site’s ownership model; the important point is to evaluate authorship, editing of others’ work, publishing, deletion, and private reading independently.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build archives, single views, and queries

Use WordPress’s standard archive and single-template conventions or a deliberate WP_Query for listings. A public CPT with an archive typically needs an archive template that loops over records, while an individual record needs a single template that renders its fields and taxonomy terms.

Template and query checklist

  • Confirm the archive URL and the single-record URL after registration.
  • Render title, content, featured image, excerpt, author, fields, and taxonomy terms only when the relevant supports or data exist.
  • Use the registered post type in custom queries rather than relying on a broad post query.
  • Define ordering and pagination explicitly when the editorial workflow requires it.
  • Provide an intentional no-results state for empty archives and filtered listings.
  • Check search behavior, previews, revisions, and canonical links.

Keep URL slugs, rewrite bases, and taxonomy names stable once the records are public. If a change is unavoidable, plan redirects and flush rewrite rules in a controlled deployment.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Test the complete workflow before launch

A registration that appears in the admin menu is only the beginning. Test the content type as an editor, visitor, API client, and administrator.

  1. Create a record: verify the menu label, editor screen, enabled supports, required fields, taxonomy controls, autosave, and revision behavior.
  2. Save each status: test draft, pending, scheduled if used, private, and published records.
  3. View the front end: open the archive, a single record, taxonomy archives, search results, previews, and paginated pages.
  4. Check data: confirm fields are validated and sanitized, values survive edits, and empty values do not break templates.
  5. Exercise roles: test authors, editors, administrators, and any restricted role for create, edit-own, edit-others, publish, delete, and private-read actions.
  6. Exercise REST: test public and authenticated requests, schema output, create and update operations, and each exposed meta field.
  7. Change the theme: verify that the CPT remains registered when it is owned by the plugin and that templates degrade safely if the new theme lacks specialized files.
  8. Deploy safely: activate the plugin, flush rewrite rules through its lifecycle hooks, and verify existing links and redirects.

Common problems and precise fixes

The type is missing after a theme switch

The registration is probably in the theme. Move the durable definition to a plugin, then verify that the plugin is active and that the registration runs on init.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The archive or single URL returns a 404

Check the has_archive and rewrite values, confirm that the registration runs, and flush rewrite rules once through activation or a controlled settings action. Also check for a slug collision with a page, taxonomy, or another post type.

The block editor or REST route is unavailable

Confirm show_in_rest is true, the type is registered on every request, and the current user has the required capability. A private or draft record can remain inaccessible even when the route itself exists.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

The taxonomy appears inconsistently

Register it with register_taxonomy() and connect it explicitly to the CPT. Check that the taxonomy’s object type includes the correct post-type key and that its own visibility and REST settings match the intended use.

Editors can see a screen but cannot publish or edit others’ records

Review capability_type, the explicit capabilities mapping, map_meta_cap, and the primitive capabilities assigned to the role. Test ownership-specific actions rather than relying on the presence of the menu item.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Private data appears in an API response

Inspect registered meta exposure and the controller schema. Remove fields that do not belong in the API, add the appropriate permission checks, and retest unauthenticated and authenticated responses.

Plugin or theme: a practical decision

Ownership choice Strength Risk or trade-off Best fit
Plugin Content remains registered when the theme changes Templates and presentation still need theme integration Content that must survive redesigns, migrations, or theme replacement
Theme Registration and presentation can be packaged together The type disappears from the admin when the theme is switched Content that is intentionally inseparable from a short-lived theme

For most durable editorial content, use a plugin for the data model and capabilities, then let the active theme provide templates and styling. This separation makes a redesign less likely to remove the content type from the editing workflow.

A maintainable implementation checklist

  • Use a unique key of 20 characters or fewer with allowed lowercase characters, numbers, dashes, or underscores.
  • Register the CPT from a plugin on init.
  • Set labels, public/query visibility, archive behavior, rewrite settings, and REST exposure intentionally.
  • Enable only the supports the editorial workflow uses.
  • Register each taxonomy separately and connect it to the CPT.
  • Store structured attributes in registered post meta or a field-management layer.
  • Validate and sanitize values before saving, and escape them when rendering.
  • Design capability mappings and assign primitive capabilities to roles during lifecycle events.
  • Flush rewrite rules on activation or deactivation, never on every request.
  • Test archives, singles, taxonomy pages, search, pagination, REST, previews, revisions, and every relevant role.
  • Keep public slugs, rewrite bases, taxonomy names, and API field names stable after launch.

How to decide whether a CPT is the right abstraction

A CPT is a strong fit when the content has a repeated shape, a distinct editorial workflow, and a reason to be queried or displayed separately. It is not automatically the best answer for a one-off page, a simple label, or an attribute that belongs naturally on an existing post. Start with the content’s identity and lifecycle, then choose supports, taxonomies, fields, templates, REST exposure, and capabilities as consequences of that model.

The implementation is complete only when the data survives a theme change, editors can perform exactly the actions intended, public and private records respect their permissions, URLs resolve predictably, and integrations receive a deliberately limited API representation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.