What are custom post types in WordPress?

Custom post types expand content types beyond posts and pages, like portfolios or events. Registering a custom post type in functions.php enables users to display specific content types separately.

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