Reputation: 653
I am using wordpress as my cms..
i had need to schedule post programmatically every 60 seconds
This is the code i am using
function techento_data_valid_schedule($data) {
if ($data['post_type'] == 'post') {
if ($data['post_status'] == 'publish') {
// If post data is invalid then
$time += 60;
$data['post_status'] = 'future';
$data['post_date'] = date('Y-m-d H:i:s', $time);
$data->edit_date = true;
}
}
return $data;
}
add_filter( 'wp_insert_post_data', 'techento_data_valid_schedule', '99', 2 );
but when i publish the post... it sets the date to jan 1. 1970 ? Am unable to find the error in the codes ?
Upvotes: 1
Views: 102
Reputation: 15780
You're not setting your $time
value anywhere, so when you get to the line $time += 60
, you're getting $time = 0 + 60
which, in unixtime is Jan 1, 1970 at 00:01:00.
To correct this, you need to set your $time
variable to whatever you need. If you want it to be the current time, try $time = time();
and then add 60 seconds.
Upvotes: 2