What is considered the post’s creation date for wp_insert_post?

The short answer is, post_date and post_date_gmt will be set to the date you scheduled the post to be published – not the date you created the post -, so post_date and post_date_gmt are holding the publishing date. Update: As reply to comment: When will the wp_insert_post hook be triggered? Actually both times, so on … Read more

Make future posts visible to the public—not just within WP_Query

In short, you can make future posts visible by telling WordPress to mark them as ‘published’ instead of ‘scheduled’. You do this by using a future_post hook, which gets called when a post changes status. Each post type automatically gets its own future hook; since the custom post type I’m using is event, I can … Read more

Why doesn’t wp_update_post() update the post_status field?

Answer couldn’t be simpler. As pointed out by Otto at the wp-hackers list, problem was me not setting post_date_gmt when using wp_update_post(). Final code looks like this: if ( $post_date < strtotime( “tomorrow” ) ) { $status=”publish”; $newpostdata[‘post_status’] = $status; $newpostdata[‘post_date’] = date( ‘Y-m-d H:i:s’, $post_date ); // Also pass ‘post_date_gmt’ so that WP plays … Read more