I have a product section on my wp-site. I am trying to display the attached thumbnail image in specific sizes that are automatically cropped to the right size.

I have used Advanced Custom Fields to create a field called product_thumbnail I have used Additional Image Sizes to create a new image size called products I have used the following code on another word press site and it worked fine, but on my current site it returns empty.

<?php $image = wp_get_attachment_image_src(get_field('product_thumbnail'), 'products'); ?>
<a href="<?php the_permalink(); ?>"><img src="<?php echo $image[0]; ?>" /></a>

I have ran a batch to make sure my images are created if not already. This is boggling my mind. Any help appreciated.

1 Answer 1


why OH WHY does everybody insist on making custom fields for everything .

is there a special reason that you would want the use of custom fields ? If so, please explain exactly what you want to achieve . If not - a much better approach (and more fool-proof for non-computer-savvy-clients) would be to use the_post_thumbnail(); - like you stated in your question already, with Additional image sizes in the theme .

I do not want to duplicate my answers - so you just as well read here :

Display thumbnail from custom field

Basically you will use

<a href="<?php the_permalink(); ?>"><img src="the_post_thumbnail('your_size_name');" /></a>
  • Thanks. There is no reason to use custom fields besides trying to make it all one area where the user adds info. This was helpful, I just swapped it for the featured image method.
    – ofatbacco
    Jan 15, 2012 at 21:33
  • ACF also allows fields to be marked as required and can really narrow the margin of admin errors for those non-computer-savvy-clients so I'm unclear on @krembo99 's aversion to it.
    – cfx
    May 16, 2014 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.