To add a custom post type to a WordPress site, you would use the register_post_type()
function. For example, to create a custom post type called “Books,” you would add the following code to your functions.php file:
function custom_post_type() {
$args = array(
'public' => true,
'label' => 'Books'
);
register_post_type( 'books', $args );
}
add_action( 'init', 'custom_post_type' );
PHPThis code creates a custom post type called “Books” and adds it to the WordPress site. You can then use this custom post type to add and display books on your site.