Is there anyway to pull in Media using added Media Tags using a looper?

Is there anyway to pull in Media using added Media Tags using a looper? Or does it have to be a custom post type? Was trying to easily add a bunch of images to a grid on a page and had this thought. I was able to add media-tags through a function. But don’t see a way to pull in Media directly.

Thanks!
Jen

Hi Jen,

Thanks for reaching out.
The Medias are stored as Attachment post types. You can use that post type in the Query String like the following one and use the {{dc:post:id}} to get the ID and {{dc:post:permalink}} to get the URL.

post_type=attachment&post_mime_type=image&posts_per_page=12&post_status=any

Please remember that the above code will work if copied as it is and doesn’t conflict with any existing style.
Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle.
We really do not provide support for custom codes which means we can’t fix it in case it conflicts with something on your site nor will we enhance it. Further customization should be directed to a third-party developer or you can avail of One, where we answer the questions beyond normal theme support.

Thanks

1 Like

Great!! I was able to make that work after some fiddling and have it filter by the media tags I added:

post_type=attachment&post_mime_type=image&tax_query%5B0%5D%5Btaxonomy%5D=post_tag&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D=blackfutures2023&posts_per_page=20&post_status=any

Thanks again,
Jen

Hi Jen,

Glad that we are able to help you.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.