WordPress.org

Make WordPress Core

Opened 9 months ago

Last modified 4 weeks ago

#45516 reviewing defect (bug)

Auto Draft title issue for custom post types

Reported by: rajanit2000 Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: minor Version: 5.0
Component: Posts, Post Types Keywords: has-patch 2nd-opinion
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 (3)

Screenshot from 2018-12-07 14-19-05.png (20.2 KB) - added by rajanit2000 9 months ago.
45516.patch (562 bytes) - added by rajanit2000 9 months ago.
Add default title option
Screen Shot 2019-08-22 at 3.46.40 PM.png (174.9 KB) - added by donmhico 4 weeks ago.

Download all attachments as: .zip

Change History (16)

@rajanit2000
9 months ago

Add default title option

#1 @rajanit2000
9 months ago

  • Keywords has-patch added

#2 @SergeyBiryukov
9 months 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.


2 months ago

#4 @nrqsnchz
2 months 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
8 weeks 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.


8 weeks ago

#7 @nrqsnchz
8 weeks ago

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

@rajanit2000 What title were you expecting to see?

#8 @rajanit2000
8 weeks ago

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

#10 @SergeyBiryukov
8 weeks 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.


7 weeks ago

#12 @garrett-eclipse
7 weeks 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
4 weeks 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

Note: See TracTickets for help on using tickets.