WordPress failing to insert post into the database

I was recently trying to insert imported data into WordPress. When trying to insert it into WordPress using wp_insert_post, I was receiving the following error:

Could not insert post into the database

It turns out that I was trying to insert data in a non-utf8 encoding, whereas WordPress uses UTF8 internally. All I had to do was run the following PHP function to convert it over to UTF8:

$post_content = iconv('ISO-8859-1','UTF-8', $post_content)

1 thought on “WordPress failing to insert post into the database”

  1. i have same issue occuring when i insert image the message displayed could not insert post into database.. if someone now please helped me.. as soon as possibile..


Leave a Comment