View list of all attachments on site
I’m new to WordPress theme development and I’m trying to figure out if there is a way to display a list of public attachments similar to how you can view a list of posts with a specific tag or author.
That is, if I want to retrieve a list of posts with a specific tag, I can submit something like ‘?tag=mytag’ in the URL and WordPress will spit out all the posts tagged with ‘mytag’. So what is the equivalent of this for viewing attachments? Or is there one?
What I’m specifically wanting to do is allow the user to click a link and have a gallery of attachments (images, video, music, etc) display. I want attachments from ALL posts on the site, not just attachments of one specific post.
I’ve looked into the attachment.php file, but this seems to only be to display the details of a specific attachment with a given attachment_id value (ie: ‘?attachment_id=246’).
Can someone steer me in the right direction?