Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#21586 closed enhancement (fixed)

Telling register_post_type to not support anything

Reported by: sc0ttkclark Owned by: nacin
Milestone: 3.5 Priority: normal
Severity: minor Version:
Component: Posts, Post Types Keywords: has-patch commit
Focuses: Cc:


As the use of WP becomes more complex, post types are getting used in more interesting ways. This is evident by a use-case for passing an empty array to the 'supports' argument. Essentially, the Post Type becomes an object relatable to taxonomies and custom fields.

If an empty array() is sent (or any empty value), WordPress currently sets the defaults to 'title' and 'editor':


I believe an alternate value should be able to passed such as false, where no defaults will get set. Currently, my work around is to pass an array, but place a faux value within it like '_placeholder'. This keeps the array from being empty and defaults set.

I'll have the patch ready by morning but feel free to provide any input positive/negative on this.

Attachments (2)

21520.patch (1.3 KB) - added by markoheijnen 8 years ago.
21586.patch (586 bytes) - added by sc0ttkclark 8 years ago.
Patch for the supports argument to be false, so as to not add support for the defaults

Download all attachments as: .zip

Change History (9)

#1 @sc0ttkclark
8 years ago

  • Cc lol@… added

My patch would basically contain a change to this line:


} else {


elseif ( false !== $args->supports ) {

#2 @markoheijnen
8 years ago

Had this once and inserted the string 'false' as a value what does work since it isn't existing.

Wouldn't it be better to have array('title', 'editor') in the defaults array. That will remove the if/else check.

8 years ago

#3 @sc0ttkclark
8 years ago

  • Keywords has-patch dev-feedback added

+1 on that Marko, I had over assumed based on existing code there was a reason not to accept an empty value. Hopefully there wasn't, your solution would be best IMO.

#4 @sc0ttkclark
8 years ago

  • Severity changed from normal to minor

Minor patch, changing to minor severity

#5 @nacin
8 years ago

  • Keywords commit added; dev-feedback removed
  • Milestone changed from Awaiting Review to 3.5

I feel like the original purpose of a default was to use it only if no 'supports' arg was passed in at all. Setting array() should explicitly say "don't support anything."

That might break too much random code — so, false seems good for now.

8 years ago

Patch for the supports argument to be false, so as to not add support for the defaults

#7 @nacin
8 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [21831]:

Allow supports => false to be passed to register_post_type() to disable the default title and editor.

An empty array may also disable all default features in the future.
Do not rely on this behavior: always specify title and editor if you want them.

props sc0ttkclark.
fixes #21586.

Note: See TracTickets for help on using tickets.