Title: Displaying a clickable image
Last modified: August 22, 2016

---

# Displaying a clickable image

 *  [angexlynne](https://wordpress.org/support/users/angexlynne/)
 * (@angexlynne)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/displaying-a-clickable-image/)
 * Hi,
 * I am using an image custom field that allows for more than one instance to displaying
   thumbnails on a product page. I am using this chunk of code to display them
 *     ```
       <ul id="product-images">
           <li>
              <img src='<?php echo types_render_field("product-image", array("raw"=>"true","separator"=>"'></li><li><img src='")); ?>'>
           </li>
        </ul>
       ```
   
 * but I want to be able to click on them and they open in a new tab/window.
    I 
   started by surrounding the images with an ‘a’ tag and put the same ‘types_render_field’
   tag in the href but that didn’t work properly and got messy with the ‘separators’
   after the first image and link. Then I tried to implement something along these
   lines
 *     ```
       <?php if ( get_post_meta( get_the_ID(), 'product-image', true ) ) : ?>
           <a href="<?php the_permalink() ?>">
               <img src="<?php echo get_post_meta( get_the_ID(), 'product-image', true ); ?>"  />
           </a>
       <?php endif; ?>
       ```
   
 * but I couldn’t get this to work either.
 * Any suggestions?
    Here is the link to my site and product page I am referring
   to [ARC Crafts](http://test.arccrafts.com.php53-19.ord1-1.websitetestlink.com/products/cherry-wood-sheet-8-5x11-adhesive-backing-bulk/)
 * [https://wordpress.org/plugins/types/](https://wordpress.org/plugins/types/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Marcin Pietrzak](https://wordpress.org/support/users/iworks/)
 * (@iworks)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/displaying-a-clickable-image/#post-5545813)
 * Dear angexlynne
 * You use code:
 *     ```
       get_post_meta( get_the_ID(), 'product-image', true );
       ```
   
 * But usually field name in Types have prefix `wpcf-`, then you should use:
 *     ```
       get_post_meta( get_the_ID(), 'wpcf-product-image', true );
       ```
   
 * Function `types_render_field` know about this prefix (this function know when
   is no prefix too) and add this.
 * Could you check and confirm or not?
 * Cheers,
 * Marcin
 *  Thread Starter [angexlynne](https://wordpress.org/support/users/angexlynne/)
 * (@angexlynne)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/displaying-a-clickable-image/#post-5545832)
 * Hi Marcin,
 * Thank you for your response. I was traveling all day yesterday but I will try
   this right now and let you know. Thank you
 * Ange
 *  Thread Starter [angexlynne](https://wordpress.org/support/users/angexlynne/)
 * (@angexlynne)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/displaying-a-clickable-image/#post-5545833)
 * Awesome, that worked.Now how can I get it to show or loop through all instances
   of that field? I have more than one photo.
 * Thank

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Displaying a clickable image’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/types_ced1d3.svg)
 * [Toolset Types - Custom Post Types, Custom Fields and Taxonomies](https://wordpress.org/plugins/types/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/types/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/types/)
 * [Active Topics](https://wordpress.org/support/plugin/types/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/types/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/types/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [angexlynne](https://wordpress.org/support/users/angexlynne/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/displaying-a-clickable-image/#post-5545833)
 * Status: not resolved