0
我在我的根wordpress文件夾中有一個名爲wp_insert_post.php的文件中有以下代碼 但是,當我從瀏覽器運行此URL時,我只是得到一個空白頁。沒有任何回聲語句出現。我究竟做錯了什麼? 在此先感謝!WordPress的wp_insert_post功能不工作
<?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";
?>
在你的error_log裏有什麼東西嗎? – Achrome
數組語法錯誤。數組應該是$ post = array('menu_order'=> 0,'page_template'=> null .... –
是的,這是問題,謝謝! – Dave