Tell us what you are trying to do?
I'm working on a real estate site with a CPT called "Woningen" and I want to delete all attached Images/media except the Featured Image when a "woning" (House) is set to the custom taxonomy "Verkocht". (Sold)
Is there any documentation that you are following?
Found something that comes close to what i want but does not filter on taxonomy, only on post Status "Publish"
It removes the images and media except the featured on saving but does not remove the Toolset gallery (empty) thumbs in the backend and still show the filename.
So it's working on a post by post basis, which is tedious.
That's why i tried to use the bulk edit function to save/update multiple posts with the status "sold" all at once.
This removes all attachments and meta but somehow also removes the featured images of these post. How is that possible?
What am i missing?
I can see that you added the code to that is used to unset the featured image:
$attachments = get_attached_media( 'image', $post->ID );
$featured_id = get_post_thumbnail_id();
//unset the featured image by ID if it exists
unset($attachments[$featured_id]);
I already guide you how you can use the save_post hook with Toolset, now you need to add the custom code as per your requirement. If you are not sure how it works, you may also consider taking help fro Pro Developers.
The code works when saving or updating a post but only partially when using the "Bulk edit" option.
I will figure out why there is a difference in how wordpress handles the save_post hook differently when using "bulk edit". I think this is out of scope for Toolset.