WordPress.org

Ready to get started?Download WordPress

Forums

creating a scheduled post with wp_insert (2 posts)

  1. vincej
    Member
    Posted 1 year ago #

    Hi, I import data from csv file.
    I want to create posts programmatically, and using wp_insrt I cannot see a "scheduled" post-status.
    I see.

    'post_date' => [ Y-m-d H:i:s ] //The time post was made.
    'post_date_gmt' => [ Y-m-d H:i:s ] //The time post was made, in GMT.
    'post_status' => [ 'draft' | 'publish' | 'pending'| 'future' | 'private' | custom registered status ] //Set the status of the new post.

    If I use "future' in my array, I do not get a scheduled post.. I just get a 'published" post.

    The wanted result is a scheduled post, say an hour from NOW !
    Any help?

  2. vincej
    Member
    Posted 1 year ago #

    oops, sorry.. that should have been using wp_update($post).

    There is a bug here I think.
    I have not tested the wp_insert yet... but with wp_update the bug is:
    if a post already exists and is published, using wp_update to change status does not work. Time is changed to future, but post remains "published".

    i.e. setting a previously published post to "scheduled in the future" will not work.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.