Home Forums Backend Issues (wp-admin) "Featured image" still intact upon removal Reply To: "Featured image" still intact upon removal

  • Hi @hube2, thanks again for your support with my previous question. I have another one that’s related.

    The above code works for both back-end post creation and also front-end post creation (by public users).

    However, I noticed that when looking in the media browser the images, although assigned as thumbnails, are not “attached” to any particular posts.

    Is there a way the image can be “attached” to the post too when submitted from the front-end?

    I have a plugin that deletes all associated post content upon post deletion (all attached media), which is why I’d like to get this working too.

    Here’s the code that created the post from the front end:

    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
    function my_pre_save_post( $post_id ) {
        // Create a new application post
        $post = array(
    		'post_status' => 'publish',
    		'post_type'   => 'application',
        // insert the post
        $post_id = wp_insert_post( $post );
        // return the new ID
        return $post_id;

    Many thanks.