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
1 Answer
Reset to default 0use 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
版权声明:本文标题:wp query - How to get taxonomy image attached to a Post Type WordPress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745275702a2651171.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论