2012-02-27 22 views
1

您好,我已經爲wordpress製作了一個PHP腳本,它通過wp_insert_post使用自定義類型插入新帖子。 使用上面的代碼我可以得到帖子保存,但我不能使用管理面板進行編輯。我想知道爲什麼?有誰能夠幫助我?將wp_insert_post()用於自定義帖子類型帖子已保存但不可編輯

$post = array(
    'comment_status' => 'closed', 
    'post_author' => 1, 
    'post_date' => date('Y-m-d H:i:s'), 
    'post_content' => $postdata['name'], 
    'post_status' => 'publish', 
    'post_title' => strtoupper(strip_tags($postdata['name'])), 
    'post_type' => 'xCustom' // custom type 


); 

wp_insert_post($post); 

謝謝

回答

2

的WordPress將所有自定義後類型蛞蝓爲小寫,所以不是使用:

'post_type' => 'xCustom' 

您應該使用:

'post_type' => 'xcustom' 

我只花了3小時在我自己的網站上進行故障排除。

相關問題