WordPress is standard using a max of 20 characters for the custom post type name. You can add the code for a new custom post type in your functions.php but if the name is longer than 20 characters WordPress doesn’t accept it.
I’ve searched for it and found the solution to get a custom post type with a name longer than 20 characters:
- Open in /wp-includes the post.php file and search for the following line:
if ( strlen( $post_type ) > 20 )
return new WP_Error( ‘post_type_too_long’, __( ‘Post types cannot exceed 20 characters in length’ ) );
- Change this line to: (I took 50 characters in my example)
if ( strlen( $post_type ) > 50 )
return new WP_Error( ‘post_type_too_long’, __( ‘Post types cannot exceed 50 characters in length’ ) );
- Then open your database and edit the wp_posts > post_type column from 20 characters to 50 characters.
Remember that if you update WordPress you need to do these steps every time.