Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#55152 new defect (bug)

Cannot delete post content if the title is empty

Reported by: wpdans's profile wpdans Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.1
Component: Posts, Post Types Keywords:
Focuses: Cc:


I installed WordPress on my new website at
I've created a custom theme and custom fields and taxonomies for "post", in a custom php file, that is called in functions.php.

When I try to test and see if custom fields are saved, I noticed something interesting: when the WordPress default post title (the_title) is empty, and the_content and custom fields are filled, I cannot delete the content that's in "the_content" on update or on save draft.

I can delete content from custom fields and it works, but if the content is not empty, I try to delete the content and save draft, the content is still there.

However, after testing, I've found that if "the_title" is not empty, I can delete the content that's located in "the_content".

The problem accrues only when "the_title" (The default post title) is empty.

I am not sure, but I think it doesn't have any relation to the custom fields. However, I I didn't tested it on a site without custom fields.

I hope that I described it clearly, if you have any questions please ask.

Change History (3)

#1 @azouamauriac
2 years ago

  • Component changed from General to Posts, Post Types

#2 @SergeyBiryukov
2 years ago

  • Summary changed from I thing I've found a bug (Not sure) to Cannot delete post content if the title is empty

Hi there, welcome to WordPress Trac! Thanks for the report.

Just linking to some related tickets here: #17115, #30775, #54983.

#3 @peterwilsoncc
2 years ago

  • Version changed from 5.9 to 2.1

Hi @wpdans and welcome to trac!

This is due to a block of code in wp_insert_post() that prevents the saving of empty posts. wp_insert_post() is used for updating posts too.

A post is considered empty if the post's title, content and excerpt are empty. The filter wp_insert_post_empty_content is available to allow developers to modify what causes a post to be considered empty.

This only applies to post types supporting the title, content (editor support) and excerpt (such as the built in post and pages post types).

Some history of this check can be seen in #18713, #2390 and #3097. I've updated the version listed on this ticket to 2.1 to indicate when the check was introduced.

I don't think the behavior you are seeing is a bug but I'll keep the ticket open for now as it may be possible to fine tune how the check works.

Note: See TracTickets for help on using tickets.