我正在使用wp_insert_post
创建帖子。在执行该函数时,我还使用一些变量设置发布日期以安排发布日期。
以下是我的代码部分:
//Intervals
$intsecond = (isset($_POST[\'awpht_time_second\'])) ? $_POST[\'awpht_time_second\'] : 0;
$intminute = (isset($_POST[\'awpht_time_minute\'])) ? $_POST[\'awpht_time_minute\'] : 0;
$inthour = (isset($_POST[\'awpht_time_hour\'])) ? $_POST[\'awpht_time_hour\'] : 0;
$intday = (isset($_POST[\'awpht_time_day\'])) ? $_POST[\'awpht_time_day\'] : 0;
$intmonth = (isset($_POST[\'awpht_time_month\'])) ? $_POST[\'awpht_time_month\'] : 0;
$intyear = (isset($_POST[\'awpht_time_year\'])) ? $_POST[\'awpht_time_year\'] : 0;
// Blog Local Time that can be splitted
$base_year = date(\'Y\', current_time( \'timestamp\') );
$base_month = date(\'m\', current_time( \'timestamp\') );
$base_day = date(\'d\', current_time( \'timestamp\') );
$base_hour = date(\'H\', current_time( \'timestamp\') );
$base_minute = date(\'i\', current_time( \'timestamp\' ) );
$base_second = date(\'s\', current_time( \'timestamp\') );
for($i=0; $i<10; $i++ ) {
$awyear = ($i * $intyear) + $base_year;
$awmonth = ($i * $intmonth) + $base_month;
$awday = ($i * $intday) + $base_day;
$awhour = ($i * $inthour) + $base_hour;
$awminute = ($i * $intminute) + $base_minute;
$awsecond = ($i * $intsecond) + $base_second;
$postdate = date($awyear.\'-\'.$awmonth.\'-\'.$awday.\' \'.$awhour.\':\'.$awminute.\':\'.$awsecond);
//Check If Post Already Exist/ Prevent Duplicates
if (!get_page_by_title($awpharritle[$i], \'OBJECT\', \'post\')){
$awpht_the_posts[$i] = array(
\'post_title\' => $awpharritle[$i],
\'post_content\' => $awpht_content{$i},
\'post_date\' => $postdate,
\'post_status\' => \'publish\',
\'post_author\' => 1,
);
// Insert the post into the database
$awpht_post_id = wp_insert_post( $awpht_the_posts[$i]);
}
每次执行该代码时,它都会返回一个通知:Notice: A non well formed numeric value encountered in C:\\xampp\\htdocs\\wordpress\\wp-includes\\functions.php on line 4028
上面的代码有什么问题吗?是否有其他方法可以基于自定义间隔以编程方式批量安排发布?请不要向我推荐插件。顺致敬意,