Here is the code that worked. I had to get rid of the foreach loop and reference the array directly:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$productimgs = get_post_meta( $post->ID, 'productimg', true );
$image_color = $productimgs[0]['product-image-color'];
$image_bw = $productimgs[0]['product-image-bw'];
$imgclr = wp_get_attachment_image_src( $image_color, 'grid-large' );
$imgbw = wp_get_attachment_image_src( $image_bw, 'grid-large' );
echo '<li>';
echo '<a href="' . get_permalink () . '"><img class="desat" src="' . $imgbw[0] . '" />';
echo '<img class="sat" src="' . $imgclr[0] . '" /></a>';
echo '</li>';
?>
Related Posts:
- Remove Dimension from wp_get_attachment_image
- Change wp_get_attachment_image attributes (src and srcset) on specific custom field
- How do I make a custom field choose an image?
- Extend WP Customizer to make multiple image selection possible
- Add multiple images to a page sidebar
- Display thumbnail from custom field
- Add custom field to image editor
- Display info from custom fields in all images’ HTML
- automatically set “Featured Image” the same as the og:i that is set in a custom field
- copy attachments to another post type and change attachment url
- limit amount of photos uploaded per cpt post
- Metabox with multiple fields added by user and upload box
- Add WYSIWYG to Image Description field
- Get Meta from Custom Field of Image URL
- Add url from Custom Field as ‘Featured Image’. Code not working
- How to display multiple images in custom field
- How to add image attachment to post from a single meta key (Woocommerce)
- Exclude images uploaded via meta boxes from WordPress gallery
- How to add the image URL from an external RSS feed and insert into a custom field?
- Add new image block, set default class name and update it using Javascript
- Better way to save image in custom field
- How do I add an image upload, custom field to a WooCommerce product?
- For homepage images (for small business website), is it better to use custom fields or post_thumbnail?
- Select multiple images from custom field
- Displaying page image in the footer automatically
- Get image url using image id
- Show image if author meta (profile fields) exists outside loop
- Convert attachment ID into url?
- Custom field as featured image caption
- Display a different image for each page with editor
- Image upload and path to custom field
- How to get custom image field of specific post id
- Selectively hiding or allowing thumbnails of featured images on front page
- wp_get_attachment_image_src() with advanced custom fields returning empty
- Unable to select image with custom field
- Users uploaded image and matching an id or taxonomy
- Adding Facebook’s image and meta description retrieval capabilities to a WordPress post
- Show image depending on the number in the custom fields
- How to delete attachments associated with custom field type when post property changes? [closed]
- Use a different catalog image than the featured image
- How to add custom fields to images for image source text and URL
- Get first URL from custom field, download and set as featured image on post publish
- Change path to child of page when uploading image via custom field
- Analyze uploaded images to get colour values
- Adding thumbnails for non-image attachments
- Upload image to wordpress
- Undefined Variable (Displaying image via custom field)
- Multiple image uploader under editor?
- Add image custom attribute [closed]
- How to mark a image attachment as background image?
- Crop custom image size vs actual size
- Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
- WP_Query – Order results by meta value
- How can I add an image upload field directly to a custom write panel?
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- getting all values for a custom field key (cross-post)
- How to add a custom field in the advanced menu properties?
- Custom query with orderby meta_value of custom field
- How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
- Using meta query (‘meta_query’) with a search query (‘s’)
- Can I exclude a post by meta key using pre_get_posts function?
- Add validation and error handling when saving custom fields?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Show Custom Fields in Quick Edit
- Where are custom field values stored in the database
- Validating Custom Meta Box Values & Required Fields
- Max length of meta_value
- Add custom fields to wp native gallery settings
- How to fix missing custom fields after upgrading to WordPress 4.8.1?
- How to enable custom fields for pages (if not a bad practice)?
- How can I add extra attribute in the ‘Page Attribute’ section in wp-admin for pages?
- Is there a way to set default custom fields when creating a post?
- Custom post meta field effect on the performance on the post
- How to get custom post meta using REST API
- Custom field/meta populated by dropdown of existing posts?
- Difference between meta keys with _ and without _ [duplicate]
- Is there any action filter/hook for validating a custom field before publishing the post?
- Orderby meta_value only returns posts that have existing meta_key
- Underscores in custom fields
- What is the index [0] for on post meta fields?
- What is “meta_input” parameter in wp_insert_post() used for?
- Query Posts or Get Posts by custom fields, possible?
- How to enable revisions for post meta data?
- Sortable Custom Columns in User Panel (users.php)?
- Any way to add custom options to Gallery Settings?
- The “_encloseme” Meta-Key Conundrum
- ORDER BY custom field value
- Individual Widgets per Page
- Add subtitle to Woocommerce product title
- Best way to programmatically remove a category/term from a post
- Importing data for advanced custom fields plugin?
- Gutenberg add a custom metabox to default blocks
- SQL Query to copy value of a meta_key into another meta_key
- ‘Preview Changes’ for custom meta boxes?
- Adding a custom field to the site identity menu
- Using TinyMce with textareas in meta boxes on custom post types
- Filter WP_Query for posts having a certain meta-value
- How to correctly call custom field dates into a posts_where filter using SQL statements
- Using get_post_meta with new_to_publish
- Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)