Say you have a library website, and you want to have a custom post type named Books. It can be registered as
function create_bookposttype() {
$args = array(
'public' => true,
'labels' => array(
'name' => __( 'Books' ),
'singular_name' => __( 'Book' )
),
);
register_post_type( 'custompost_books', $args );
}
add_action( 'init', 'create_bookposttype' );
and, as simple as that is, you now have a custom post type registered.
This snippet can be placed in your theme functions.php
file, or within a plugin structure.