📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials WordPress Development Custom Post Types

Custom Post Types

5 min read Quiz at the end
Custom post types create new content types — register with register_post_type() and set show_in_rest.

Custom Post Types (CPT)

 [
            'name'          => 'Portfolio',
            'singular_name' => 'Project',
            'add_new_item'  => 'Add New Project',
        ],
        'public'       => true,
        'has_archive'  => true,
        'show_in_rest' => true,     // enables Gutenberg + REST API
        'menu_icon'    => 'dashicons-portfolio',
        'supports'     => ['title','editor','thumbnail','excerpt'],
        'rewrite'      => ['slug' => 'portfolio'],
    ]);
}
add_action('init', 'register_portfolio_cpt');

// After registering: flush permalinks
// Settings > Permalinks > Save Changes
// Or: flush_rewrite_rules();
Topic Quiz · 1 questions

Test your understanding before moving on

1. Which function registers a Custom Post Type?
💡 register_post_type() is the WordPress function for creating custom content types.