[英]Wordpress wp_insert_post function not working
I have the following code in my root wordpress folder in a file called wp_insert_post.php However when I run this url from the browser I just get a blank page. 我在我的root wordpress文件夹中有一个名为wp_insert_post.php的文件中的以下代码。然而,当我从浏览器运行此URL时,我只得到一个空白页面。 None of the echo statements appear.
没有出现任何echo语句。 What am I doing wrong?
我究竟做错了什么? Thanks in advance!
提前致谢!
<?php
require_once('wp-config.php');
error_reporting(E_ALL);
ini_set('display_errors',1);
echo "done1";
$post = array(
'ID' => []
'menu_order' => ['0']
'page_template' => []
'comment_status' => ['closed']
'ping_status' => ['open']
'pinged' => [] //?
'post_author' => ['1']
'post_category' => []
'post_content' => ['testautopage123']
'post_date' => ['2013-05-18 18:39:33']
'post_date_gmt' => ['2013-05-18 18:39:33']
'post_excerpt' => []
'post_name' => ['test-auto-page']
'post_parent' => []
'post_password' => []
'post_status' => ['publish']
'post_title' => ['Test Page']
'post_type' => ['page']
'tags_input' => []
'to_ping' => []);
echo "done2";
// Insert the post into the database
wp_insert_post($post);
echo "done3";
?>
Your format is not good. 你的格式不好。 Try it like this ( taken from the codex )
试试这个(取自codex )
$my_post = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(8,39)
);
// Insert the post into the database
wp_insert_post( $my_post );
So, remove the [
and ]
and add commas ,
after each parameter in the array. 这样,删除
[
和]
,并添加逗号,
阵列中的每个参数之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.