Home › Forums › Add-ons › Gallery Field › Reverse lookup a post, that an image is attached to using \"Gallery\" › Reply To: Reverse lookup a post, that an image is attached to using \"Gallery\"
If your gallery field is not a sub field of a group or repeater then the meta query would look something like this:
'meta_query' => array(
array(
'key' => 'gallery_field_name',
'value' => '"'.$attachment_id.'"',
'compare' => 'LIKE'
)
)
If it’s a sub field then it gets far more complicated, see the section on sub fields here https://www.advancedcustomfields.com/resources/query-posts-custom-fields/
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.