• I am participating in the #AtoZ blog challenge, and for the first time, I have set up draft posts for A – Z.

    I did not realize that the date ALL of those posts is “keeping” is the date I created the post, not the date of last save or the I am publishing.

    Here is a screenshot of my drafts folder. All say “Last modified 3/12/16”, which is actually the date I created the posts.

    I only realized this issue when I went to check out my blog and my A post wasn’t there… it was, just hiding down below everything I’ve published since then. I manually corrected the date and it popped back up on top, where it should be.

    So, without changing every single post by hand before I publish it, how can I get the date to change to now, not then?

Viewing 1 replies (of 1 total)
  • Add this to your theme’s functions.php to update the date to current date-time when you press publish on any existing draft.

    function publish_date_now( $data , $postarr ) {
    	if( isset($postarr['ID']) && get_post_status( $postarr['ID'] ) == 'draft' ) {
    		$data['post_date'] = date('Y-m-d H:i:s');
    	}
    	return $data;
    }
    add_filter( 'wp_insert_post_data', 'publish_date_now', 10, 2 );

Viewing 1 replies (of 1 total)
  • The topic ‘publish date different from last draft save’ is closed to new replies.