I write following code to save post in wordoress wp_post database table.
but don't save in database
function writeMsg(){
global $wpdb;
$result = $wpdb->get_results ( "SELECT * FROM wp_farsc" );
$data = null;
$data.= '<table border="2px" cellspacing="5px" width="100%">'.PHP_EOL;
$data.= '<tr bgcolor="yellow"><th>سکه</th><th>قیمت انلاین</th><th>تغییر قیمت</th><th>کمترین</th><th>بیشترین</th><th>زمان بروز رسانی</th></tr>'.PHP_EOL;
foreach ( $result as $row ) {
$data .='<tr>';
$data .= '<td>'.$row-> titile.'</td>';
$data .='<td>'.$row -> liveprice.'</td>';
$data .='<td>'.$row -> changing.'</td>';
$data .= '<td>'.$row-> lowest.'</td>';
$data .= '<td>'.$row-> topest.'</td>';
$data .= '<td>'.$row-> time.'</td>';
$data .='</tr>'.PHP_EOL;
}
return $data;
}
$oiobz1 = writeMsg(1, 'center', '', 1);
function importposts() {
$postdate = date('2014-06-19 00:30:00');
$postdate_gmt = date('2014-06-19 04:30:00');
$titles=' 111111111111111111111111111';
$posts = array(
'post_content' => $oiobz1,
'post_name' => $titles,
'post_title' => $titles,
'post_type' => 'post',
'post_author' => '1',
'ping_status' => 'publish',
'to_ping' => 'http://rpc.pingomatic.com/',
'post_date_gmt' => $postdate_gmt,
'post_date' => $postdate,
);
$post_id = wp_insert_post($posts);
add_post_meta($post_id, 'META-KEY-1', 'META_VALUE-1', true);
}
?>
importposts
?