wordpress 添加文章

connect_error) {
    die("连接失败: " . $con->conect_error);
} 
 
$sql = "SELECT * FROM Myposts limit 0,1000";
$result = $con->query($sql);
 
if ($result->num_rows > 0) {
    // 输出数据
    while($row = $result->fetch_assoc()) {
        
		$mydate = $row["mytime"];

		
		$my_post = array(
		  'post_title'    => $row["mytitle"],
		  'post_excerpt'  => $row["myexcerpt"],
		  'post_date'     => MyGetDate($mydate),
		  'post_date_gmt' => MyGetDate($mydategmt),
		  'post_content'  => $row["mycontent"],
		  'post_status'   => 'publish',
		  'post_author'   => 1,
		  'post_category' => array(1)   //  文章所在分类 ID
		);
		// 插入文章到数据库
		wp_insert_post( $my_post );
	
    }
} else {
    echo "0 结果";
}
$con->close();
?>

 

你可能感兴趣的:(wordpress)