The MU forums have moved to WordPress.org

Future Posting (4 posts)

  1. peiqinglong
    Member
    Posted 16 years ago #

    I know when you set a post with a future date, it won't *appear* until that day and time in question, but what if I wanted it to appear. Is there a way to query it so that if there is a future posting, it will appear? Thanks!

  2. drmiketemp
    Member
    Posted 16 years ago #

    Change the date and time back to something before teh current time and resave it. It should show right up.

  3. peiqinglong
    Member
    Posted 16 years ago #

    Dr.Mike, thanks, but I should be more clear. What I'm trying to accomplish for our office intranet site is an events blog. We have events planned two or more weeks in advance. It wouldn't be an effective events blog if it only displays the current date. I want to be able to display an event posted today for an event that will occur in future.

    I realize this might be somewhat backwards thinking, but I have plans for this.

  4. intoxination
    Member
    Posted 16 years ago #

    It would require a plugin (untested):

    add_action("save_post","changeFuturePost");
    
    function changeFuturePost($post_ID){
         global $wpdb;
         $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID=$post_ID");
         if ($post->post_status=="future"){
              $wpdb->query("UPDATE $wpdb->posts SET post_status='publish' WHERE ID=$post_ID");
              wp_clear_scheduled_hook('publish_future_post', $post_ID);
              do_action('publish_post', $post_ID);
         }
    }

    Like I said, it's not tested, but should give you a general idea of what needs to be done.

About this Topic

  • Started 16 years ago by peiqinglong
  • Latest reply from intoxination