post_content is stripping HTML when adding a new post? [closed]

When WP inserts a post one of the things it does is check both the current user’s capabilities, and which html tags are allowed to be used. There are two ways to modify this:

Method 1: wp_kses_allowed_html hook

You can modify the allowed set of html tags, given a context, by using this filter:

https://codex.wordpress.org/Function_Reference/wp_kses_allowed_html

Method 2: unfiltered_html capability

This is a much broader solution, and adds the capability for the user to put whatever html wanted, into a post.

Note that you need to be careful about simply adding that capability to a role that a logged-in user will have access to because it may create unintended security exposures. Another way to do this is to add the capability to the current user at the time needed, within the context when it is required by using the map_meta_cap hook.

This way the capability is transient and will only be employed at the time it’s needed.