小编jos*_*nte的帖子

Wordpress - 使用insert_post时的db_insert_error

我目前正在使用每天自动更新的CSV文件,以便为客户的网站创建或更新Wordpress帖子.CSV具有列表的地址,城市,州等的标题,每行是另一个列表.目前,CSV中有大约220个属性.除了其中三个之外的所有内容都是作为帖子创建的,但其中有三个不是,而且我得到的是像这样的WP_Error - >

 WP_Error { 
       "errors"=> array{ ["db_insert_error"]=> 
                array{ [0]=> "Could not insert post into the database" }}
       "error_data"=> array { } 
       "ID"=> int(0) 
       "filter"=> "raw"
 }
Run Code Online (Sandbox Code Playgroud)

我知道插件至少可以工作,因为所有其他插件都已发布,但似乎这三个由于某种原因正在出现此错误.它们中没有任何特殊字符或其他数据可以将它们与其他行区分开来.这是我用来创建新帖子的数组和代码:

$new_post = array(
        'post_title'   => $title,
        'post_content' => wpautop(convert_chars($data['csv_post_post'])),
        'post_status'  => $opt_draft,
        'post_type'    => 'listing',
        'post_date'    => $this->parse_date($data['csv_post_date']),
        'post_excerpt' => '....',
        'post_name'    => $data['csv_post_slug'],
        'post_author'  => $this->get_auth_id($data['csv_post_author']),
        'tax_input'    => $this->get_taxonomies($data),
        'post_parent'  => $data['csv_post_parent'],
);
$pricecheck = trim($data['_listing_price']);
Run Code Online (Sandbox Code Playgroud)

$title地址,城市和州的预加入字符串在哪里.

if (!get_page_by_title( $new_post['post_title'], 'OBJECT', 'listing') && $pricecheck != "") {
    $id = wp_insert_post($new_post, …
Run Code Online (Sandbox Code Playgroud)

php csv wordpress genesis

2
推荐指数
1
解决办法
3806
查看次数

标签 统计

csv ×1

genesis ×1

php ×1

wordpress ×1