我必须在Wordpress中按程序插入帖子。我希望我应该能够通过url发布帖子。比如www.mypage。com/insertnewpost。php?标题=废话(&A);内容=blahblahblah&;类别=1,2,3
以下代码只有在函数内部使用时才起作用。主题的php文件。
include \'../../../wp-includes/post.php\';
global $user_ID;
$new_post = array(
\'post_title\' => \'My New Post\',
\'post_content\' => \'Lorem ipsum dolor sit amet...\',
\'post_status\' => \'publish\',
\'post_date\' => date(\'Y-m-d H:i:s\'),
\'post_author\' => $user_ID,
\'post_type\' => \'post\',
\'post_category\' => array(0)
);
$post_id = wp_insert_post($new_post);
然而,当我尝试创建像insertnewposts这样的新页面时。php并使用上面的代码,我会遇到一些错误,如致命错误:调用Z:\\www\\wordpress\\wp includes\\post中未定义的函数add\\u action()。php在线144请帮忙。