Quick Edit in WordPress Corrupts Publish Date on Posts in ‘Draft’ Status

Quick Edit in WordPress Corrupts Publish Date on Posts in Draft Status

When using the Quick Edit feature of WordPress (verified in versions 3.7, 3.7.1, and 3.8) on any post in a ‘Draft’ status, the publish date will set itself to the date and time the Quick Edit occurred, leading to an invalid and incorrect published date when the publish of the post finally occurs.

The consequences of this publish date corruption occurring can be significant, and there are three very specific consequences noted below as a result of this publish date becoming set on a draft post.

Consequence #1. When editing a post in a ‘Draft’ status, using the full edit mode, the Publish immediately option is no longer available. Rather, it shows the date and time that was set when the Quick Edit occurred, and subsequent changes to the publish date have to be set manually. If not updated when the post is finally published, this leads to a publish date occurring in the past and can cause the post to not appear as the most recent post in your blog, if other posts were created and published after the draft was initially created.

Consequence #2. The post permalink, which will traditionally update itself while editing a draft to reflect the current post title, no longer updates itself based upon the current title but becomes fixed to the title that was updated when using the Quick Edit feature. If you want to change the permalink, it requires an update to the title before publishing and becomes a manual process.

Consequence #3. Caching plugins that can automatically expire the cache if an update is made to a post, and that leverage to post_date_gmt column in the wp_posts table to determine when to do so, will start automatically expiring the cache when a draft is saved, an unnecessary and possibly very expensive step, in terms of cache regeneration.

Resolution

To resolve the problems created by the Quick Edit feature of WordPress automatically setting the publish date of a post in ‘Draft’ status, the post_date_gmt column of the post in a ‘Draft’ status needs to be updated to reflect the appropriate value of ‘0000-00-00 00:00:00‘.

The following SQL has been provided to update the post_date_gmt column of the wp_posts table. The SQL below will find all posts within the wp_posts table, that have a value of draft in the post_status column, and update the post_date_gmt column to the correct non-published value.

UPDATE wp_posts SET post_date_gmt = '0000-00-00 00:00:00' WHERE post_status = 'draft';

Executing the SQL as shown above will restore the functionality lost when the publish date was automatically set using the Quick Edit feature, and reset the post’s publish date back to the default publish date of ‘0000-00-00 00:00:00‘.

Author: daharveyjr

I’m a solution architect responsible for the design, development, implementation, testing, and maintenance of e-commerce operations and applications using the Hybris and WebSphere Commerce product suites and other web technologies such as Java, J2EE/JEE, Spring, PHP, WordPress and more. Twitter | Facebook | LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *