Php Wordpress自定义邮件

Php Wordpress自定义邮件,php,wordpress,Php,Wordpress,我正试图用Wordpress中模板的代码创建自定义帖子 <div class="demo"> <?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

我正试图用Wordpress中模板的代码创建自定义帖子

 <div class="demo">     
<?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); ?>
</div>

这似乎没有在页面上显示帖子?


 <div class="demo">     
<?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); ?>
上面的代码所做的是插入一个新帖子

这似乎没有在页面上显示帖子

 <div class="demo">     
<?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); ?>
你在这里要做的是插入一篇新文章。如果你想让帖子显示出来,试试下面的代码

<?php get_post( $post_id ); ?>


我在index.php文件中添加了这个。我是否需要将它添加到函数中,然后从index.php调用它?执行
$post\u id=wp\u insert\u post($new\u post,true)时是否会收到有用的错误消息;变量转储($post\u id)?别介意,我误解了你的问题。我如何让它显示帖子?可能与我需要放置的位置重复,因为每次我刷新页面时,它都会不断创建帖子。