Custom Post Type

A Custom Post Type in WordPress is a content type beyond the default ones like Posts and Pages. It allows developers and site owners to create structured content tailored to specific use cases – such as portfolios, testimonials, events, products, or services.

Built-in Post Types in WordPress

WordPress comes with several built-in post types:

  • post – blog posts
  • page – static pages
  • attachment – media uploads
  • revision – content revisions
  • nav_menu_item – menu items

What Is a Custom Post Type?

Custom Post Types behave like posts or pages, but they can have their own admin menu, templates, metadata, taxonomies, and URLs.

Example: Registering a Custom Post Type

function create_movie_post_type() {
    register_post_type('movie', [
        'labels' => [
            'name' => 'Movies',
            'singular_name' => 'Movie'
        ],
        'public' => true,
        'has_archive' => true,
        'rewrite' => ['slug' => 'movies'],
        'supports' => ['title', 'editor', 'thumbnail'],
    ]);
}
add_action('init', 'create_movie_post_type');

Use Cases

  • Portfolios – for designers or agencies
  • Testimonials – client reviews
  • Events – with custom fields like date, location
  • Products – when not using WooCommerce
  • Team Members – structured staff bios

Displaying CPT Content

To display custom post type content on the frontend, you can:

  • Use WP_Query with post_type => 'your_type'
  • Create custom templates: single-glossary.php, archive-glossary.php
  • Use page builders or CPT-compatible blocks

Summary

FeatureDescription
What it isCustom content type beyond Posts and Pages
Use casesPortfolios, Events, Products, Testimonials, etc.
How to registerregister_post_type() in functions.php or plugin
Template supportCustom single and archive templates
EnhancementsWorks with taxonomies, custom fields, Gutenberg, REST