Pods CMS – Get ACT’s attached image records by auto-id?

You’re right, the attachments are stored within a separate table called wp_podsrel. Within the table you’ll find the item_id (coupon id) and the related_item_id (attachment id).

Hence you can get all the related_item_id‘s as a function of the item_id:

SELECT related_item_id FROM wp_podsrel WHERE item_id = $coupon_id

Your complete query/output may look something like this:

// global $wpdb;
$coupon_id = 1; // custom coupon id
$podsrel = $wpdb->prefix . 'podsrel';

$select_coupon_related_item_ids = $wpdb->prepare( "SELECT related_item_id FROM $podsrel WHERE item_id = %d AND related_item_id NOT IN ( %d )", $coupon_id, 1 );
$coupon_related_item_ids = $wpdb->get_results( $select_coupon_related_item_ids, OBJECT );

foreach ( $coupon_related_item_ids as $coupon_related_item_id ) :
  $coupon_image_url = wp_get_attachment_url( $coupon_related_item_id->related_item_id );
  var_dump( $coupon_image_url );
endforeach; 

Make sure that you’re only selecting related attachment id’s (and not any other related items)! Feel free to expand the query with your custom field_id if necessary. Or let me know if you need further help! 🙂