Così dovrebbe andare:
codice:
<?php
// Carica WordPress nel tuo script
require_once 'path/to/wp-load.php';
// Carica i dati dal tuo file
$myfilename="contenuto.txt";
$myarray=file($myfilename, FILE_IGNORE_NEW_LINES);
// Cicla
foreach ($myarray as $item){
// Crea il post e inseriscilo
$id = wp_insert_post(array(
'post_title' => $item,
'post_content' => '',
'post_type' => 'post',
'post_status' => 'publish',
));
}
Ovviamente devi avere una installazione completa di wordpress per caricare il file wp-load.php