WordPress.org

Ready to get started?Download WordPress

Forums

Making posts far into the future using wp_insert_post causing errors (2 posts)

  1. Rambomst
    Member
    Posted 1 year ago #

    I am having issues using wp_insert_post when posting far into the future. If I make a post for the next couple of days it works fine however if I make it to be posted in a month or two it will be posted straight away and isn't being displayed in the admin area under 'Posts'

    The code I am using is:

    //This is what the value of $imageDate looks like.
    $imageDate = '2012-10-30';
    if($imageDate != false)
    {
    $imagePost = array(
    'post_title' => $imageTitle,
    'post_content' => 'Content added later.',
    'post_status' => 'future',
    'post_date' => $imageDate . " 00:00:00",
    'post_author' => 1,
    'tags_input' => "'".$imageTags."'",
    'post_category' => array(1)
    );
    }
    else
    {
    $imagePost = array(
    'post_title' => $imageTitle,
    'post_content' => 'Content added later.',
    'post_status' => 'publish',
    'post_author' => 1,
    'tags_input' => "'".$imageTags."'",
    'post_category' => array(1)
    );
    }

    $postID = wp_insert_post($imagePost);

  2. Rambomst
    Member
    Posted 1 year ago #

    Still haven't found a solution for this. Any help is much appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic