What is a custom post type, and how do you create one?

Custom post types allow developers to create new content types beyond posts and pages. Registering a custom post type in functions.php with register_post_type lets you display unique content formats, like portfolios or testimonials.

function create_custom_post_type() {
    register_post_type('portfolio',
        array(
            'labels' => array('name' => __('Portfolio')),
            'public' => true,
            'has_archive' => true,
        )
    );
}
add_action('init', 'create_custom_post_type');