Post scheduling lets you set a future time for your content to appear automatically. Post status shows if a post is draft, published, or pending.
Post scheduling and status in Wordpress
<?php // Schedule a post to publish later $post = array( 'ID' => 123, // existing post ID 'post_date' => '2024-07-01 10:00:00', // future date and time 'post_status' => 'future' // status for scheduled posts ); wp_update_post($post); // Change post status wp_update_post(array( 'ID' => 123, 'post_status' => 'draft' // or 'publish', 'pending', 'future' )); ?>
Use 'future' status to schedule posts for future publishing.
Post statuses include 'draft', 'publish', 'pending', and 'future'.
<?php // Schedule a post to publish on July 1, 2024 at 10 AM wp_update_post(array( 'ID' => 123, 'post_date' => '2024-07-01 10:00:00', 'post_status' => 'future' )); ?>
<?php // Save a post as draft wp_update_post(array( 'ID' => 123, 'post_status' => 'draft' )); ?>
<?php // Publish a post immediately wp_update_post(array( 'ID' => 123, 'post_status' => 'publish' )); ?>
This code creates a new post scheduled for one day from now. It then prints the post ID and its status, which will be 'future'.
<?php // Example: Schedule a new post and check its status $post_data = array( 'post_title' => 'My Scheduled Post', 'post_content' => 'This post will appear later.', 'post_status' => 'future', 'post_date' => date('Y-m-d H:i:s', strtotime('+1 day')), 'post_author' => 1 ); // Insert the post $post_id = wp_insert_post($post_data); // Get the post status $status = get_post_status($post_id); echo "Post ID: $post_id\n"; echo "Status: $status\n"; ?>
WordPress uses the 'future' status to mark posts scheduled for later publishing.
Always use the correct date format 'Y-m-d H:i:s' for scheduling.
Scheduled posts will automatically publish at the set time without manual action.
Post scheduling sets a future publish time using 'post_date' and 'future' status.
Post status controls visibility: 'draft' for unfinished, 'publish' for live, 'pending' for review, and 'future' for scheduled.
Use wp_insert_post or wp_update_post to set scheduling and status in WordPress.