Make WordPress Core

Opened 7 years ago

Last modified 16 hours ago

#45516 reopened defect (bug)

Auto Draft title issue for custom post types

Reported by: rajanit2000's profile rajanit2000 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.9 Priority: normal
Severity: minor Version: 5.0
Component: Posts, Post Types Keywords: has-copy-review has-screenshots has-test-info has-patch has-unit-tests needs-testing
Focuses: administration Cc:

Description

I have register post type without title support

$labels = array(
	'name'               => _x( 'Social posts', 'post type general name', 'text-domain' ),
	'singular_name'      => _x( 'Social post', 'post type singular name', 'text-domain' ),
	'menu_name'          => _x( 'Social posts', 'admin menu', 'text-domain' ),
	'name_admin_bar'     => _x( 'Social post', 'add new on admin bar', 'text-domain' ),
	'add_new'            => _x( 'Add New', 'social-post', 'text-domain' ),
	'add_new_item'       => __( 'Add New Social post', 'text-domain' ),
	'new_item'           => __( 'New Social post', 'text-domain' ),
	'edit_item'          => __( 'Edit Social post', 'text-domain' ),
	'view_item'          => __( 'View Social post', 'text-domain' ),
	'all_items'          => __( 'All Social posts', 'text-domain' ),
	'search_items'       => __( 'Search Social posts', 'text-domain' ),
	'parent_item_colon'  => __( 'Parent Social posts:', 'text-domain' ),
	'not_found'          => __( 'No social-posts found.', 'text-domain' ),
	'not_found_in_trash' => __( 'No social-posts found in Trash.', 'text-domain' )
);
$args = array(
	'labels'             => $labels,
	'description'        => __( 'Description.', 'text-domain' ),
	'public'             => true,
	'publicly_queryable' => true,
	'show_ui'            => true,
	'show_in_menu'       => true,
	'query_var'          => true,
	'rewrite'            => array( 'slug' => 'social-post' ),
	'capability_type'    => 'post',
	'has_archive'        => true,
	'hierarchical'       => false,
	'menu_position'      => 10,
	'menu_icon'          => 'dashicons-id',
	'delete_with_user'   => true,
	'can_export'         => true,
	'show_in_rest'       => true,
	'supports'           => array( 'editor' )
);
register_post_type( 'social-post', $args );

And if i add post the list post page shows title as "Auto Draft"

Attachments (5)

Screenshot from 2018-12-07 14-19-05.png (20.2 KB) - added by rajanit2000 7 years ago.
45516.patch (562 bytes) - added by rajanit2000 7 years ago.
Add default title option
Screen Shot 2019-08-22 at 3.46.40 PM.png (174.9 KB) - added by donmhico 6 years ago.
45516.2.diff (573 bytes) - added by garrett-eclipse 5 years ago.
Refreshed patch to take into account copy review of (no title supported)
Screen Shot 2020-10-16 at 11.59.20 PM.png (18.6 KB) - added by garrett-eclipse 5 years ago.
Test of a post type that doesn't support title

Download all attachments as: .zip

Change History (63)

@rajanit2000
7 years ago

Add default title option

#1 @rajanit2000
7 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
7 years ago

  • Component changed from Editor to Posts, Post Types
  • Focuses administration added

This ticket was mentioned in Slack in #design by boemedia. View the logs.


6 years ago

#4 @nrqsnchz
6 years ago

Hi @rajanit2000!

Would you mind clarifying what the issue is?
Is the fact that the list post page shows the title as "Auto Draft" a bug? Where you expecting something else?

#5 @rajanit2000
6 years ago

I have registered a new post type and its only support "editor" using this code

'supports'           => array( 'editor' )

And create a post in this post type and published it. But the listing page only shows the title is "Auto Draft"

Does it make sense?

Refer my screen record
https://www.loom.com/share/ebadb2bd8f934c20bc96d1841bef04f8

This ticket was mentioned in Slack in #core by rajanit2000. View the logs.


6 years ago

#7 @nrqsnchz
6 years ago

But the listing page only shows the title is "Auto Draft"

@rajanit2000 What title were you expecting to see?

#8 @rajanit2000
6 years ago

@nrqsnchz I think "No Title" is the better word

#10 @SergeyBiryukov
6 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

This ticket was mentioned in Slack in #design by karmatosed. View the logs.


6 years ago

#12 @garrett-eclipse
6 years ago

  • Keywords 2nd-opinion added; ui-feedback removed

Thanks @rajanit2000 the patch looks good. Discussing in #design Slack (A WordPress.org slack account is required to view that link) today and the idea of making the string a customizable label when registering the post type seems like it could have some merit. Going to switch this from ui-feedback to 2nd-opinion to get thoughts on if having it be a customizable label makes sense or if just going with '(no title)' here is the extent we want to go here.

#13 @donmhico
6 years ago

Thanks for the ticket @rajanit2000. I'm no longer able to reproduce the issue. I can't find the exact Changeset at the moment. But what I can tell is that class-wp-posts-list-table.php - https://core.trac.wordpress.org/browser/tags/5.2/src/wp-admin/includes/class-wp-posts-list-table.php#L1007 - uses _draft_or_post_title() - https://developer.wordpress.org/reference/functions/_draft_or_post_title/ - to determine the title displayed in wp-admin/edit.php.

I used the same code as you provided above to create a custom post type without title support. And what I tried to create a post. This is what I can see - https://core.trac.wordpress.org/attachment/ticket/45516/Screen%20Shot%202019-08-22%20at%203.46.40%20PM.png

#14 @garrett-eclipse
6 years ago

  • Milestone changed from 5.3 to 5.4

Thanks @donmhico for testing, I ran through myself and was able to reproduce the issue on Trunk w/ Twenty Twenty and the code provided in the description. Looking at the code base when you go to add a post it creates the auto-draft w/ title of 'Auto-Draft'. Reviewing code there's a few ways you can avoid the auto-draft such as disabling the functionality or providing a post_title on the request, you can also avoid it by programatically creating the post. @donmhico maybe you circumvented it somehow, would you mind retesting on trunk and confirm you are or aren't seeing the issue now.

As there's some work to be done here and a decision needed on behaviour I'm going to move this into 5.4 to address there.

The item requiring 2nd-opinion is;
"Going to switch this from ui-feedback to 2nd-opinion to get thoughts on if having it be a customizable label makes sense or if just going with '(no title)' here is the extent we want to go here."
@SergeyBiryukov do you have any thoughts on a customizable label or just using (no title)?

Version 0, edited 6 years ago by garrett-eclipse (next)

#15 @donmhico
6 years ago

@garrett-eclipse - I used a fresh installation using the trunk after you get my attention to re-test and:

  1. I was able to reproduce the error now.
  2. The fix still applies cleanly.

Regarding the use of '(no title)', maybe we can use something like '(Not supported)' or '(Not applicable)' instead? Creating a post without a title in a post types that support titles uses '(no title)' which indicates that the post has no title but can have a title. So using a label that indicates that title isn't supported on post types that doesn't support it seems like a better idea. What do you guys think?

#16 @garrett-eclipse
6 years ago

  • Keywords needs-copy-review added

Thanks @donmhico for confirming, and I agree it is a little misleading which may be a reason to go with the custom label option there. Leaving open for opinion and marking for some copy-review would be nice to get thoughts on an alternative to (no title) in the cases the post type doesn't support titles.

#17 @rajanit2000
6 years ago

When this ticket will be solved?

This ticket was mentioned in Slack in #meta by rajanit2000. View the logs.


6 years ago

#19 follow-ups: @garrett-eclipse
6 years ago

Hi @rajanit2000 I milestoned this into 5.4 and hope it is addressed within that release. It's currently awaiting a 2nd-opinion and needs-copy-review which will hopefully come once devs start working through the 5.4 milestone.
*In hopes of getting a copy-review going to ping @marybaum

Mary, the part specific to copy review;
'would be nice to get thoughts on an alternative to (no title) in the cases the post type doesn't support titles.'

#20 in reply to: ↑ 19 @marybaum
6 years ago

Replying to garrett-eclipse:

Hi @rajanit2000 I milestoned this into 5.4 and hope it is addressed within that release. It's currently awaiting a 2nd-opinion and needs-copy-review which will hopefully come once devs start working through the 5.4 milestone.
*In hopes of getting a copy-review going to ping @marybaum

Mary, the part specific to copy review;
'would be nice to get thoughts on an alternative to (no title) in the cases the post type doesn't support titles.'

I'm on it! Thanks for the heads-up!

#21 @audrasjb
6 years ago

  • Milestone changed from 5.4 to Future Release

Hi,

Looks like this patch unfortunately still needs copy review.

With 5.4 Beta 3 approaching and the Beta period reserved for bugs introduced during the cycle, this is being moved to Future Release. If any maintainer or committer feels this should be included or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.

#22 in reply to: ↑ 19 @bridgetwillard
5 years ago

Copy Review of "(no title)"

Hi @garrett-eclipse am I understanding this correctly?

The CPT doesn't support any title whatsoever.

Therefore, the Title is Not Applicable.

Suggested Copy

'(N/A)' or '(Title Not Applicable)' or '(Title N/A)'

Replying to garrett-eclipse:

Hi @rajanit2000 I milestoned this into 5.4 and hope it is addressed within that release. It's currently awaiting a 2nd-opinion and needs-copy-review which will hopefully come once devs start working through the 5.4 milestone.
*In hopes of getting a copy-review going to ping @marybaum

Mary, the part specific to copy review;
'would be nice to get thoughts on an alternative to (no title) in the cases the post type doesn't support titles.'

#23 @garrett-eclipse
5 years ago

Thanks @bridgetwillard greatly appreciated, yes that's the part and concept exactly. Re-reading I wonder if we use the 'support' term that's used in the register_post_type() method as documented here (search 'supports');
https://developer.wordpress.org/reference/functions/register_post_type/

Maybe just append 'supported' to what we have already;
(no title supported)
Or
(title not supported)

Thoughts?

#24 @bridgetwillard
5 years ago

  • Keywords has-copy-review added; needs-copy-review removed

Excellent point, @garrett-eclipse.

I would go with (no title supported).

'(title not supported)' feels unclear to me.

Cheers.

@garrett-eclipse
5 years ago

Refreshed patch to take into account copy review of (no title supported)

@garrett-eclipse
5 years ago

Test of a post type that doesn't support title

#25 @garrett-eclipse
5 years ago

  • Keywords commit added; 2nd-opinion removed
  • Milestone changed from Future Release to 5.6

Thanks for the copy review @bridgetwillard I've updated the patch in 45516.2.diff I think this is good to go so am going to see if we can land it in 5.6.

@SergeyBiryukov would you like to review the latest please.

#26 @garrett-eclipse
5 years ago

  • Keywords has-screenshots added

#27 @SergeyBiryukov
5 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 49288:

Posts, Post Types: Set better default title for custom post types without title support.

The default title is now set to "(no title supported)" instead of "Auto Draft".

Props garrett-eclipse, rajanit2000, bridgetwillard, donmhico, nrqsnchz.
Fixes #45516.

#28 @TimothyBlynJacobs
5 years ago

Has this been tested against Gutenberg? The plugin does some manual checks against "Auto Draft" being the title.

#29 @SergeyBiryukov
5 years ago

  • Keywords has-patch commit removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Thanks, reopening to see if any additional changes are needed.

#30 @SergeyBiryukov
5 years ago

  • Keywords needs-testing added

#31 @SergeyBiryukov
5 years ago

It looks like line 475 in core-data package needs an update to account for the new value as well.

Haven't found any other instances.

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


5 years ago

#33 @joyously
5 years ago

It seems like the Post List Table class should check for title support and use something else to differentiate the posts if no title is supported. How is the user supposed to find the post to edit when the link is on the title, which isn't supported? (I guess they will have code to add a column for something else.)

#34 @hellofromTonya
5 years ago

Notes from today's scrub:

Per Sergey

Here: https://github.com/WordPress/gutenberg/blob/c33f007d70ed5978d433b1069af23db1c2d94c2f/packages/core-data/src/actions.js#L475
It's not quite clear why it only seems to compare to a non-translated title :thinking_face:
I can open an issue [ie in GB]

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


5 years ago

#36 @helen
5 years ago

  • Milestone changed from 5.6 to 5.7

Reverting this from 5.6 and moving to 5.7 to try again due to lack of update in Gutenberg package and being ~24 hours from RC. I would like to think through a different string as well if we could, (no title supported) manages to be both too technical and not descriptive enough at the same time for me, which makes it sound alarming or like something has gone wrong if you are not somebody who understands that you can turn off title support for a post type.

More broadly I do not love when CPTs do this and have the admin interface exposed without coming up with a user-friendly way of differentiating items. Not sure if there's also something we can do here to nudge them a certain way.

Last edited 5 years ago by helen (previous) (diff)

#37 @helen
5 years ago

In 49614:

Posts, Post Types: Go back to "Auto Draft" for CPTs without title support.

Reverts [49288] due to late point in 5.6 cycle and lack of update in Gutenberg package to account for the string change.
See #45516.

#38 @hellofromTonya
5 years ago

@SergeyBiryukov Did you get a chance to open an issue upstream in Gutenberg for this one? See notes in slack https://wordpress.slack.com/archives/C02RQBWTW/p1604951464174800

#39 @hellofromTonya
5 years ago

  • Milestone changed from 5.7 to Future Release

With 5.7 RC1 landing tomorrow and no activity on this ticket since 5.6, punting this ticket to Future Release.

If any maintainer or committer feels this can be resolved in time, or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.

#40 follow-up: @Cybr
3 years ago

If the post type had support for titles but lost it, the last stored value will be unalterable but still used.

Therefore, I think it's best to (also) have a post_type_supports() check in single_post_title().

This (extra) check may impact developers that deliberately removed support but have prefilled the value. But I think this is where they had to filter single_post_title instead.

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


2 months ago

#42 in reply to: ↑ 40 @SirLouen
2 months ago

  • Keywords has-test-info has-patch has-unit-tests added; needs-testing removed

Test Report

Description

✅ This report validates that the indicated patch works as expected.

Patch tested: https://core.trac.wordpress.org/attachment/ticket/45516/45516.2.diff

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.29
  • Server: nginx/1.29.1
  • Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 139.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Testing Dolly 1.0.0
    • Test Reports 1.2.0

Testing Instructions

  1. Add the code in the first post (remember to add it to a function and hook it into init)
  2. Publish a new post to the new CPT called "Social Posts"
  3. 🐞 Title return wrongly "Auto Draft"

Actual Results

  1. ✅ Issue resolved with patch, adding "No title supported". (By the default a post without title displays just "No title")

Additional Notes

Replying to Cybr:

This (extra) check may impact developers that deliberately removed support but have prefilled the value. But I think this is where they had to filter single_post_title instead.

I think this is worth another report. Although it's correlated, it is an entirely different topic.

  • Added a Unit Test for this.

Supplemental Artifacts

https://i.imgur.com/JEcra9N.png

This ticket was mentioned in PR #9597 on WordPress/wordpress-develop by @SirLouen.


2 months ago
#43

Adding Unit Tests to the patch 45516.2.diff

Trac ticket: https://core.trac.wordpress.org/ticket/45516

This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.


2 months ago

This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.


2 months ago

This ticket was mentioned in Slack in #core-test by nikunj8866. View the logs.


2 months ago

This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.


8 weeks ago

#48 @mosescursor
8 weeks ago

Patch Testing Issue “45516”

Test Report

Description

A custom Post type that has no Title is displayed as “Auto Draft” instead of something like No Title or UnSupported Title.

Patch tested:
[45516.2.diff​](573 bytes) - added by garrett-eclipse 5 years ago.
Refreshed patch to take into account copy review of (no title supported)

Environment

  • WordPress: 6.8.2
  • PHP: 8.2.29
  • Server: Apache/2.4.65 (Debian)
  • Database: mysqli (Server: 8.0.43 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 140.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Test CPT Without Title 1.0
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch

Additional Notes

  • Any additional details worth mentioning.

Supplemental Artifacts

#49 @SirLouen
8 weeks ago

  • Milestone changed from Future Release to 6.9

This is ready to be launched.

#50 @fakhriaz
8 weeks ago

Test Report

Description

CPT Social Post with no title displays: (no title supported) after applying the patch.

Patch tested: 45516.2.diff​ (573 bytes) - added by garrett-eclipse 5 years ago.
https://core.trac.wordpress.org/attachment/ticket/45516/45516.2.diff

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.29
  • Server: nginx/1.29.1
  • Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 140.0.0.0
  • OS: Linux
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Hello Dolly test 1.7.2
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch.

Additional Notes

  • We edited the hello.php file of Hello Dolly plugin adding the code at the first post.
  • CPT with no title displays: Auto Draft, before applying the patch (as shown below as well).

Supplemental Artifacts

Image showing test results:
https://ibb.co/tT66cpgf
The social post at the top is after applying the patch: (no title supported)
The social post at the bottom is before applying the patch: Auto Draft

#51 @SirLouen
9 days ago

  • Keywords commit added

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


9 days ago

#53 @gulamdastgir04
4 days ago

Tested the patch in the WordPress Playground using PHP 8.3 and 6.9 alpha version.

Test Report

Description

This report validates whether the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/9597

Environment

  • WordPress: 6.9-alpha-20250825.225429
  • PHP: 8.3.27-dev
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.40.1)
  • Browser: Chrome 142.0.0.0
  • OS: Linux
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

✅ Issue resolved with patch.

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


41 hours ago

#55 follow-up: @wildworks
20 hours ago

  • Keywords needs-testing added; commit removed
  • Milestone changed from 6.9 to 7.0

Since the RC1 release is coming soon, I'm punting this ticket to 7.0.

Has this been tested against Gutenberg? The plugin does some manual checks against "Auto Draft" being the title.

Based on the discussions I've read, it seems that no research or testing has yet been conducted on the points mentioned above.

Further investigation and testing are needed to determine whether this change will cause problems with the block editor or site editor, and whether any string changes are required on the Gutenberg project side.

Additionally, what would happen if title support was added to that post type later on?

  • Register a post type without title support.
  • Insert a post and save it.
  • In the post list table, it will be displayed as (no title supported).
  • Add title support to that post type.
  • In the post list table, it will be displayed as (no title supported).
  • In the post list, the post type is still displayed as (no title supported) even though it supports a title.

Perhaps, it might be possible to simply use (no title)?

#56 in reply to: ↑ 55 @SirLouen
20 hours ago

Based on the discussions I've read, it seems that no research or testing has yet been conducted on the points mentioned above.

I'm not sure what "Testing" should be driven in Gutenberg specifically. All tests have been actually done in Gutenberg as this is the default editor.

If we check the code, Auto Drafts are still being executed when they should for Gutenberg drafting purposes. The (no title supported) is only relevant when the post is actually saved, but there is no title support explicitly set at that exact moment. Currently it will be set as Auto Draft generating a faulty behavior.

Replying to wildworks:

Perhaps, it might be possible to simply use (no title)?

@wildworks the problem is that since this is not a dynamic field, this is only reflecting the current status when set.
It's like (Auto Draft). You could edit this in a million ways and still it will be saying "(Auto Draft)" until you manually change it.

(no title) is not much descriptive in regards of what is happening but (Auto Draft) is actually misbehaving.

So currently this is misbehaving and this patch will add a fix to this. It could always be reimproved but current situation is unstable.

I still believe this is a commit, and it should be committed in 6.9


Last edited 20 hours ago by SirLouen (previous) (diff)

#57 follow-up: @wildworks
20 hours ago

Let's look at an example of an inconsistency occurring in Gutenberg.

  • Register a post type without title support.
  • Insert a post and save it.
  • In the post list table, it will be displayed as (no title supported).
  • Open the block editor. The header document bar will display No title. This should be (no title supported).

I understand that there are already inconsistencies between the dashboard and the block editor for post types that do not currently support titles, but instead of fixing only a part of it, we should aim for consistency in the behavior of both the core and Gutenberg.

#58 in reply to: ↑ 57 @SirLouen
16 hours ago

  • Milestone changed from 7.0 to 6.9

Replying to wildworks:

Let's look at an example of an inconsistency occurring in Gutenberg.

  • Register a post type without title support.
  • Insert a post and save it.
  • In the post list table, it will be displayed as (no title supported).
  • Open the block editor. The header document bar will display No title. This should be (no title supported).

I understand that there are already inconsistencies between the dashboard and the block editor for post types that do not currently support titles, but instead of fixing only a part of it, we should aim for consistency in the behavior of both the core and Gutenberg.

@wildworks got you
I added a fix in Gutenberg for this.
https://github.com/WordPress/gutenberg/pull/73091

I still think we are on time to add this for 6.9.

Note: See TracTickets for help on using tickets.