Issue with wp_insert_post and post_content field error Could not update post in the database

Today, I was trying to insert an imported data into WordPress. I was using wp_insert_post to insert data, and it threw the following error:

WP_Error Object (
    [errors] => Array
    (
        [db_update_error] => Array
            (
                [0] => Could not update post in the database
            )

    )
    [error_data] => Array
    (
    )
)

My friend said me that I was trying to insert an non-utf8 encoded data, and WordPress uses UTF8 internally.

$post_info['post_content'] = iconv('ISO-8859-1','UTF-8', $post_info['post_content']);

Leave a Comment