[WordPress Plugin] Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
For custom post type - retrieving attachments don't work
$query = new WP_Query([
'post_type' => 'news',
'posts_per_page' => 5,
]);
echo '<pre>';
print_r($query->posts);
echo '</pre>';
wp_reset_query();
$attachments = new Attachments( 'attachments', 13 ); // post ID 13 has 4 attachments
echo $attachments->exist() ? 'yes' : 'no'; // result is - no. Thought it has data!
Temporary fix
Use get_post_meta to retrive post meta where meta key is attachments example - get_post_meta( $post_id, 'attachments', true ) then json decode
You will receive an array by your registered attachment eg. my_attachments
Then loop through result and use wp_get_attachment_url to get URL.
For custom post type - retrieving attachments don't work
Temporary fix
get_post_meta
to retrive post meta where meta key isattachments
example -get_post_meta( $post_id, 'attachments', true )
then json decodemy_attachments
wp_get_attachment_url
to get URL.