WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#14649 closed defect (bug) (duplicate)

Throw error when registering a Post Type longer than 20 chars

Reported by: batmoo Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

From stephdau's blog post:

When dealing with WordPress custom post types, be sure that the namespace/value you use as an identifier for your post_type is less then or equal to 20 characters. The DB column which holds the said value is a varchar(20).

WordPress should throw either a PHP Notice or an admin_notices error warning that the post type name cannot be longer than 20 characters and fail to register the post type.

Also applies to register_post_status.

Change History (4)

comment:1 @hakre5 years ago

  • Keywords reporter-feedback added

Are you adding the post type via the admin UI? If so, please provide the URL of the page in Admin where you do this.

Even better please provide some simple steps on how to reproduce the problem.

comment:2 @stephdau5 years ago

register_post_type( 'a_really_long_post_type_namespace', ... );

The above will end up having "a_really_long_post_" only in the DB in post_type.

comment:3 @batmoo4 years ago

  • Keywords needs-patch added; reporter-feedback removed

Related #11959 and #15058

comment:4 @dd324 years ago

  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

See [16670] - Throw WP_Error if post_type passed to register_post_type() is longer than schema allows. props phrostypoison. fixes #13709

Note: See TracTickets for help on using tickets.