我从查询中调用一个整数值($ number),例如$ number = 50; 然后我想创建与interger值相同数量的帖子,例如创建50个帖子。 帖子名称为$ post_name = $ title_ $ number;
我可以使用什么php函数来创建等于整数值的帖子数量?
for ($i = 1, $i++, $i = $number){
//create new post
$my_post = array(
'post_title' => $post_title_$i
);
// Insert the post into the database
$post_id = wp_insert_post( $my_post );
}
答案 0 :(得分:0)
foreach (range(1, $max_number) as $number){
$my_post = array(
'post_title' => $post_title_$number
);
// Insert the post into the database
$post_id = wp_insert_post( $my_post );
}