I'm importing posts to my wordpress site from different sources. The import is done via script, using wp_insert_post function which works just fine.
However, some posts come with a closing div that never starts and that messes up my theme.
I noticed that this </div> tag automatically disappears if I go to in wordpress dashboard -> edit post and simply switch from visual mode to html mode without having to manually remove the div.
Now the question: is there a function in wordpress codex that is doing that and that I could run for the post_content before running wp_insert_post?
Thank you!