This is my situation. I have two plugins, one plugin will read a remote XML file and downloads content then it calls a function on another plugin to do the actual importing of posts to the WordPress database.

Now here is the problem, the second problem inserts posts using wp_insert_post method and this is a multisite implementation.

As a result, it strips div ids inside the post_content for example:

<div id="this_is_example">

Would become:


Someone suggests me to use force_filtered_html_on_import filters like this:

add_filter( 'force_filtered_html_on_import', '__return_false', 999 );

This will disable the filtering of HTML during import and will preserved the div ids inside the post_content.

I have tried adding this filter on the first plugin but it didn't work. I have a restriction to add this filter to the first plugin as the second plugin is beyond my control.

How to make this work by only adding this filter on the first plugin that do the import? This filter is not so documented by WordPress. I would appreciate any help on this one. Thanks.

1 Answer 1


The solution that I've found is to add this line just before doing the import:

        if (function_exists('kses_remove_filters')) {

That will disable the kses filters responsible for stripping HTML tag inside the post_content.

I have successfully added this to the first plugin. Once this is disabled, it seems that when the import call to the second plugin has been made, it will effectively disable these filters as well.

I hope this will help anyone having an issue of filtered HTML caused by wp_insert_post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.