I'm attemping to create a 'gallery' page for my site, which will display all images from the site, and allow users to filter those by custom post types.
Is it possible to pull in all images from a CPT and attribute them to that particular CPT so they can be filtered between?
I can pull every image from across the site using:
$attachments = get_posts( array(
'post_type' => 'attachment',
'post_status' => 'inherit',
'post_mime_type' => 'image',
'posts_per_page' => -1,
'order' => 'DESC'
) );
But how could i further customise this to pull images only uploaded to a particular CPT, the desired outcome is i can have a list of filters above that match my post types, so all images across the site can be viewed via the gallery page?
Thanks!