require('wp-blog-header.php') does not work in a loop
-
Hi,
I’m trying to use wp_insert_post from an external php file. This file works fine if there is no loop<?php require('wp-blog-header.php'); $tmpstr = array( 'ID' => 1, 'post_title' => $title, 'post_content' => $post content, 'post_status' => 'publish', 'post_author' => '1', 'post_type' => $type ); wp_insert_post($tmpstr); ?>However, when i put a loop,
`<?php
for ($i=0;$i<10,$i++) {
require(‘wp-blog-header.php’);
$tmpstr = array(
‘ID’ => 1,
‘post_title’ => $title[$i],
‘post_content’ => $post content[$i],
‘post_status’ => ‘publish’,
‘post_author’ => ‘1’,
‘post_type’ => $type
);
wp_insert_post($tmpstr);
}
?>
It insert only 1 time into mysql database, then it stops
Could anyone please help me to make it loop for 10 times, so that it can insert 10 entries?
Thank you in advance!
The topic ‘require('wp-blog-header.php') does not work in a loop’ is closed to new replies.