Custom Post Type Naming

Today I was working on a new version of a site when I noticed that I had changed how I named a custom post type. It triggered me into figuring out the best practices for naming custom post types.

After some quick research from a couple of sites, I came to a conclusion.

Custom Post Types should have a singular name, with a slug rewrite that is plural.

Here’s what registering a proper custom post type looks like:

<?php // functions.php

add_action( 'register_post_type', 'my_custom_post_type' );

function my_custom_post_type() {
    $args = [
        'label' => esc_html__( 'Books', 'textdomain'),
        'rewrite' => [
            // Produces a URL as
            'slug' => esc_html__( 'books', 'textdomain' ),
        /* additional args... */
    register_post_type( 'book', $args );