I have created a custom post type and attached it to a Custom Taxonomy. I used Advanced Custom Fields to add an image upload option to taxonomy.

But I can't retrieve image in Front End. I used below code to get the image URL. But it is not working.

<img src="<?php bloginfo('url'); ?>/wp-content/uploads/<?php echo get_post_meta(get_ani_taxonomy_fields($ani->term_id, 'acf_image_field_name'), '_wp_attached_file', true); ?>" />

How can I get this to work?

Thanks in advance

  • Can you please let me know name of"custom post type", "taxonomy" and "acf image field" so I can help you. Aug 2, 2019 at 16:53

1 Answer 1


use this snippet here i get image which have post id 5

<img src='<?php echo site_url(); ?>/wp-content/uploads/<?php echo get_post_meta(5,'_wp_attached_file',true); ?>' height="100" width="100">

check get_ani_taxonomy_fields($ani->term_id, 'acf_image_field_name') this function return post id

  • Tried. But same issue still there. :(
    – xy_pro
    Aug 2, 2019 at 10:34
  • Serach in your wp_postmeta table by post id and _wp_attached_file meta key what you get in meta value. Aug 2, 2019 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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