ACF does not support taxonomies for media files because this is not supported natively by WP. Customization needs to be done in WP to do this, either through code or by using a plugin. I’ve looked into the ACF code and there isn’t any way to filter images for a gallery by taxonomy and there isn’t any way to add taxonomies to the array of images returned.
(I suppose that you could add a load value filter https://www.advancedcustomfields.com/resources/acf-load_value/ or maybe a format value filter https://www.advancedcustomfields.com/resources/acf-format_value/ to the gallery field to add this information to the value before it is returned, but I’m not 100% sure on how to do this.)
I’m not exactly sure where you want to do this filtering.
If you want to do it in the admin you’d need to build a new type of gallery field that includes filters for your custom media taxonomy https://www.advancedcustomfields.com/resources/creating-a-new-field-type/. It may also be possible to add field settings to the existing gallery field https://www.advancedcustomfields.com/resources/adding-custom-settings-fields/ and then add filters to the gallery field to alter how it works to use these settings to filter images, but I’m not even sure this is possible. The gallery field works in conjunction with the standard WP media library popup and dealing with this can be complicated if it can be done at all.
If you want to filter them on the front end…. if it were me I’d add a filter to the gallery load value hook, or more likely I would loop though all the images that ACF returns and only show the ones that should be shown based on additional queries.
Sorry for the long answer that probably didn’t help you, but there isn’t a simple solution to this and any solution is going to involve a lot of coding to accomplish.
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!
© 2023 Advanced Custom Fields.