Make WordPress Core

Opened 21 months ago

#56555 new defect (bug)

wp_insert_post does not save the post_date for pending posts

Reported by: sweetheatmn's profile sweetheatmn Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.0.2
Component: General Keywords:
Focuses: Cc:

Description

If we set a date when inserting a post with the status of pending/draft, WordPress does not display that date when editing the post

<?php
// Create post object
$my_post = array(
                'post_title'    => 'test title'  ,
                'post_content'  => 'test content',
                'post_status'   => 'pending',
                'post_date' => '2022-09-01 10:38:00',
                'post_date_gmt' => '2022-09-01 08:38:00'
);

// Insert the post into the database
$id = wp_insert_post( $my_post );

Expected when editing the post to see the set date

https://i.imgur.com/8DSgjCq.png

current behavior: the date does not display, instead it shows "Immediately"

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

Change History (0)

Note: See TracTickets for help on using tickets.