Site icon Hip-Hop Website Design and Development

Search in posts’ attachments: title, caption, description

I have seen variations on this question here and some have pointed to this solution (which doesn’t work and is apparently syntactically incorrect as well).

I have also seen people ask about searching in the content of PDFs, or returning a list of attachments, and none of this is what I want. I want the search to just return pages and posts, like it normally does, but I want it to identify what media is attached to a page or post, and then search through the titles, descriptions and captions of that media.

If there’s a match, I want the search results to just return the post to which the media is attached, not a link to the attachment page or anything like that. How do I do this?