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.
Jack
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.