admin管理员组

文章数量:1417691

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

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

Share Improve this question asked Aug 2, 2019 at 8:21 xy_proxy_pro 1 1
  • Can you please let me know name of"custom post type", "taxonomy" and "acf image field" so I can help you. – Tanmay Patel Commented Aug 2, 2019 at 16:53
Add a comment  | 

1 Answer 1

Reset to default 0

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

本文标签: wp queryHow to get taxonomy image attached to a Post Type WordPress