Created
October 27, 2015 22:47
-
-
Save khoand0000/059cf0502dea88c7c91e to your computer and use it in GitHub Desktop.
note when saving json with unicode by json_encode()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$content = []; | |
// ... | |
$my_post = array( | |
'post_title' => 'aaa', | |
'post_content' => str_replace("\\", '\\\\', json_encode($content)), // avoid saving \u1ec5 to u1ec5 | |
'post_status' => 'pending', | |
'post_author' => 0, | |
); | |
// Insert the post into the database | |
$id = wp_insert_post($my_post); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment