2009-09-14 39 views
-1

我運行下面的一段代碼(假設所有變量都有值)是我試圖爲Joomla2Wordpress的自定義導入程序。WordPress的:wp_insert_post無法添加comment_count

$ret_id = wp_insert_post(array(
    'ID' => $pinfo, 
    'post_date' => $Posted, 
    'post_date_gmt' => $post_date_gmt, 
    'post_author' => $authorid, 
    'post_modified' => $LastMod, 
    'post_modified_gmt' => $post_modified_gmt, 
    'post_title' => $Title, 
    'post_content' => $Body, 
    'post_excerpt' => $Excerpt, 
    'post_status' => $post_status, 
    'post_name' => $sefurl, 
    'comment_count' => $comments_count) 
); 

但是,雖然代碼正確地插入帖子,但評論計數未更新(保持爲零)。 codex頁面根本沒有提到參數。

任何人都可以幫忙嗎?

+1

我認爲這可能屬於堆棧溢出... – Breakthrough 2009-09-14 11:50:27

+0

什麼是用於達到這一點的代碼? – random 2010-01-30 08:13:16

回答

1

wp_insert_post()不更新評論計數,您必須致電wp_update_comment_count_now()更新完成。