你的一个问题是
if(isset($submit)){
您在上面的行上声明$submit
$submit = $_POST[\'submit\'];
这就是为什么
isset($submit)
将始终返回TRUE并执行代码。
我想补充一下
global $user_ID;
if ( $user_ID )
{
//insert your post
}
else
{
//give that person a message "Dude, you have to sign up or login to be able to submit content..."
}
然后跳过post\\u日期,并使用您的值键入post\\u,这些值无论如何都会被添加。你传递给那个函数的次数越少,你犯的错误就越少。。。
我会尝试将此添加到您的例如功能中。php脚本
$new_post = array(
\'post_title\' => \'Test Post Title\',
\'post_content\' => \'Test Post Content\',
\'post_status\' => \'publish\',
\'post_author\' => $user_ID,
);
wp_insert_post($new_post);
这应该插入一篇带有gioven值的新闻帖子。。。如果这样做有效,您就知道必须在表单中查找错误。虽然我认为你不能将目录传递给wp\\U insert\\U post。。。。但首先尝试一下简单的测试。