Reputation: 3085
is it possible to update an already existing and published post on a certain date/time in the future? The previous version should be visible on the site until the update is done.
Possible?
Thanks!
Upvotes: 0
Views: 501
Reputation: 2263
Will it always be the same post that will get updated? In that case just create a function and hook it into wp_cron.php, check documentation here http://codex.wordpress.org/Function_Reference/wp_schedule_event an example would be something like this (put in your functions.php)
// first parameter is when it should occur, you can set this for example
// by using php's time(), which will fetch the current time, then add how much
// further in time you want the event to occur (in seconds).
wp_schedule_single_event(time()+600, 'function_that_get_called');
//the above code will run 10 minutes after functions get called.
function function_that_get_called() {
$my_post = array();
$my_post['ID'] = the_post_id; // the ID of the post you wish to update.
$my_post['post_content'] = 'New content for my post!';
wp_update_post($my_post);
}
Problem with using wordpress own cron function is that someone most have visited your site for it to fire, but I'd guess you could just add the above code to your functions.php save it and visit the site yourself right afterward and it will trigger. Make sure to add something like to the function:
error_log('my_scheaduled_event triggered!');
So you can check your php error log and see that the function actually triggered properly.
Upvotes: 0
Reputation: 2387
Not sure if this is exactly what you're looking for, but here's a plugin that allows you to schedule a portion of a page or post using shortcodes: http://wordpress.org/extend/plugins/scheduled-content/
It works like this:
<p>This paragraph is visible by default.</p>
[schedule on='2012-03-20' at="07:00"]
<p>This paragraph will be published on March 20th at 7 am.</p>
[/schedule]
Upvotes: 1