I can fix it by making sure my save_post hook runs after the post type switcher’s hook.
Hi, I have same report about it.
With plugin Advanced Custom Fields is same bug. If I have “file” field for example on page post type, my attachment was changed to “page”. So it is annoying bug!
In acf is function, which change post_parent of attachment to content (in my example tp “page”). It is called like that
wp_update_post( array(‘ID’ => $post->ID, ‘post_parent’ => $post_id ) );
Well, what im investigated
in your plugin is
add_filter( ‘wp_insert_post_data’, array( $this, ‘override_type’ ), 10, 2 );
there should be something similar
if ( $_GET[“post”] !== $data[‘ID’] )
return $data;