0

我在我的根 wordpress 文件夹中的一个名为 wp_insert_post.php 的文件中有以下代码但是当我从浏览器运行这个 url 时,我只得到一个空白页。没有任何 echo 语句出现。我究竟做错了什么?提前致谢!

<?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";
?>
4

1 回答 1

2

你的格式不好。像这样尝试(取自法典

$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 );

因此,删除数组中每个参数后的[and]并添加逗号。,

于 2013-05-19T12:24:43.913 回答