wp query - How to get taxonomy image attached to a Post Type WordPress

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

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745275702a4620026.html

相关推荐

  • wp query - How to get taxonomy image attached to a Post Type WordPress

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

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信