<?php
$submitted = $_POST['submit'];
$post-title= $_POST['post_title'];
$post-content= $_POST['post_content'];
$new_post = array(
'post_title' => '$post-title',
'post_content' => '$post-content',
'post_status' => 'publish',
'post_author' => $user_ID,
);
if(isset($submitted)){
wp_insert_post($new_post);
}
?>
<form method="post" action=" ">
<input type="text" name="post_title" size="45" id="input-title"/>
<textarea rows="5" name="post_content" cols="66" id="text-desc"></textarea>
<input type="hidden" name="cat" value="7,100"/>
<input class="subput round" type="submit" name="submit" value="Post"/>
</form>
我測試了它與表格,它工作正常。但因爲某些原因,我似乎無法讓它與表格一起工作。有任何想法嗎?wp_insert_post使用表格
還有什麼應該在表單的行動?
感謝您的幫助。
我試過它在index.php,它不起作用。沒有進入數據庫。嗯,非常感謝 – andrewk 2010-12-01 07:10:21