Hallo zusammen,
ich habe ein kleines Script zum Importieren von Daten aus einer Mysql Datenbank in die Wordpress Datenbank gefunden, das auch prima klappt. Nur müsste ich noch einige custom fields einfügen, habe aber leider keine Ahnung, wie die Syntax dafür aussieht. Also das ist der Code, den ich habe:
require("setup.php");
$conn = mysql_connect($dbhost,$dbuser,$dbpasswd);
mysql_select_db($dbname,$conn);
$results = mysql_query("SELECT * FROM data WHERE `Send` = 'No' LIMIT 10",$conn);
$i = 0;
while ($row = mysql_fetch_array($results,MYSQL_ASSOC)) {
$ID = $row['adid'];
$Title = stripslashes($row['adtitle']);
$Title = utf8_encode($Title);
$Tags1 = $row['subcatname'];
$Tags2 = $row['Cat2'];
$Tags3 = $row['Cat3'];
$Tags4 = $row['Cat4'];
$Tags5 = $row['Cat5'];
$Tags = "$Tags1, $Tags2, $Tags3, $Tags4, $Tags5";
$post = array();
$post['post_status'] = 'publish';
$post['post_category'] = array(5,6);
$post['post_date'] = date('Y-m-d H:i:s',strtotime($row['date']));
$post['post_title'] = $Title;
$post['post_content'] = $row['addesc'];
$post['tags_input'] = $Tags;
$posts[$i] = $post;
$i++;
}
mysql_free_result($results);
mysql_close($conn);
require('../wp-load.php');
foreach ($posts as $post) {
wp_insert_post($post);
}
Nach den Tags sollten jetzt noch einige custom fields mit importiert werden, kann mir da vielleicht jemand weiterhelfen ?