我正在尝试编写一个插件,如果选中一个框(值1)并且帖子id不存在,那么它将创建一个页面。如果帖子id已经存在,那么我想用所做的任何更改来更新帖子。我有创建帖子(作为页面)的部分工作得很好。但是,当我尝试运行wp\\u update\\u post时,出现以下错误:
array_merge() [function.array-merge]: Argument #1 is not an array in /home/wpovernight/wpovernight.com/wp-includes/post.php on line 2996
因为错误与post有关。php,我猜这个问题是关于wp\\u update\\u post上的数组的,但我不确定我做错了什么。我觉得一切都很好。这是我的代码:
//Check if page exists
$page_check_404 = get_page_by_title($page_title_404);
// Checks if box is checked
if ($activate_404_page == 1) {
$ss_404_page = array(
\'post_title\' => $page_title_404,
\'post_content\' => $ss_404_page_content,
\'post_status\' => \'publish\',
\'post_author\' => 1,
\'post_type\' => \'page\'
);
// If page doesn\'t exist, create it
if(!isset($page_check_404->ID)){
$ss_404_post_id = wp_insert_post( $ss_404_page );
}
//if page does exist, edit it
if(isset($page_check_404->ID)){
$ss_404_page_update = array(
\'post_title\' => $page_title_404,
\'ID\' => $ss_404_post_id,
\'post_content\' => $ss_404_page_content,
\'post_status\' => \'publish\',
\'post_author\' => 1,
\'post_type\' => \'page\'
);
wp_update_post( $ss_404_page_update );
}
}