I am using wp_insert_post to bulk insert posts into WordPress, according to http://codex.wordpress.org/Function_Reference/wp_insert_post it seems like the method does many tag manipulation for the content supplied, for example, it will replace a <br>
tag if it finds a newline n
character in the string. I wonder how could we turn this feature off, as in my case I have all the content pre-processed and I want WordPress take them as is. The kses_remove_filters()
and 'post_content_filtered' => true,
lines are my attempts to solve this problem, but it doesn’t seem to work.
kses_remove_filters();
$my_post = array(
'post_title' => wp_strip_all_tags($json_str['title'][0]),
'post_content' => $json_str['content'],
'post_date' => $json_str['pdate'],
'post_name' => $json_str['alias'][0],
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(2, $catid),
'post_content_filtered' => true,
);
wp_insert_post();
From the documentation:
In
wp-includes/post.php
line ~394, comment this line out:But it is generally a bad idea to hack core files.