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:
1
|
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:
1
|
$post_content = iconv( 'ISO-8859-1' , 'UTF-8' , $post_content) |