1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
<?php
$conn = mysql_connect('........', '.......', '.....');
mysql_select_db('.........',$conn);
$results = mysql_query("SELECT * FROM news",$conn);
$i = 0;
while ($row = mysql_fetch_array($results,MYSQL_ASSOC)) {
$post = array();
$post['post_status'] = 'publish';
$post['post_category'] = array(4);
$post['post_date'] = date('Y-m-d H:i:s',strtotime($row['date']));
$post['post_title'] = $row['titre'];
$post['post_content'] = $row['news'];
$posts[$i] = $post;
$i++;
}
mysql_free_result($results);
mysql_close($conn);
require('./wp-load.php');
foreach ($posts as $post) {
wp_insert_post($post);
}
?> |
Partager