I am inserting posts programmatically using wp_insert_post. A typical call would look like this:
$news_item = array (
'post_title' => $titleField,
'post_content' => $retrieve_result['content'],
'post_status' => 'pending',
'post_author' => $user->ID,
'post_type' => 'post',
'post_date_gmt' => $post_date_gmt
);
$post_id = wp_insert_post( $news_item );
My question is about the parameter post_date_gmt, is this a correct use? Should I use post_date instead? What value is displayed on the screen? I need explanation of both. Documentation does not offer much.
Thanks.
From the comments in the
WP_Post
class inwp-includes/post.php
:So if you’re adding a post programmatically, and you want a date attached, you should set both keys. (If you leave them blank, WordPress will use the appropriate current date for both.)