Support » Plugins » Hacks » Publish scheduled/future posts in 3.5

  • Resolved THE MOLITOR

    (@the-molitor)


    Hi there,

    I’m using the following code in my functions.php file that sets posts with a future publish date to the “published” status (instead of “scheduled”).

    Everything worked perfect until updating to WordPress 3.5. Does anybody know why?…

    function setup_future_hook() {
     // Replace native future_post function with replacement
     remove_action('future_post', '_future_post_hook');
     add_action('future_post', 'publish_future_post_now');
    }
    
    function publish_future_post_now($id) {
     // Set new post's post_status to "publish" rather than "future."
     wp_publish_post($id);
    }
    
    add_action('init', 'setup_future_hook');
Viewing 10 replies - 1 through 10 (of 10 total)
  • tomontoast

    (@tomontoast)

    tomontoast

    (@tomontoast)

    Looking more in detail at http://wpseek.com/_future_post_hook/ it seems that you may need

    function setup_future_hook() {
     // Replace native future_post function with replacement
     remove_action('future_post', '_future_post_hook');
     add_action('future_post', 'publish_future_post_now');
    }
    
    function publish_future_post_now($deprecated,$id) {
     // Set new post's post_status to "publish" rather than "future."
     wp_publish_post($id);
    }
    
    add_action('init', 'setup_future_hook');
    Andrew Nacin

    (@nacin)

    Lead Developer

    Interesting. wp_publish_post() used to do a direct database call. It was updated to use wp_update_post() in 3.5. The side effect is that it no longer forcibly publishes a post that is dated in the future. I am not sure whether pre-3.5, or post-3.5, should be considered expected behavior. Relevant Trac ticket, https://core.trac.wordpress.org/ticket/21963, and commit, https://core.trac.wordpress.org/changeset/21942.

    Try this as a workaround:

    remove_action('future_post', '_future_post_hook');
    add_filter( 'wp_insert_post_data', 'nacin_do_not_set_posts_to_future' );
    function nacin_do_not_set_posts_to_future( $data ) {
        if ( $data['post_status'] == 'future' && $data['post_type'] == 'post' )
            $data['post_status'] = 'publish';
        return $data;
    }
    THE MOLITOR

    (@the-molitor)

    Nacin, you are the man.

    shacker

    (@shacker)

    Thanks a bunch Andrew Nacin! I’ve updated the repo with your version, which should be compatible with all WP versions.

    http://wordpress.org/extend/plugins/the-future-is-now/

    Scheduled posts regression is high WordPress 3.5 bug, correct on WordPress 3.5.1-beta1!

    WP Missed Schedule correct exactly ticket #22944 and others related issues of WordPress since version 2.6 😉 ignored from core team …

    Upgrade to WordPress 3.5.1-beta1 or install my plugin WP Missed Schedule 😉

    OMG!!! You don’t know how long Ive been trying to fix this. Loaded the-future-is-now and it orked like a charm. Bought a template a week ago and haven’t been able to get it to work. Support seemed lost so I guess they owe you a thanks too.

    did this stop working in 3.5.2??

    i can’t get it to work at all – i even tried installing the “the future is now” plugin.

    This has stopped working for several of my clients as well.
    Is it a WP issue? Is there a fix coming?

    esmi

    (@esmi)

    Forum Moderator

    Nope. There are no known scheduling issues in WordPress 3.5.

    As this topic is over 7 months old, I am now closing it.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Publish scheduled/future posts in 3.5’ is closed to new replies.