I need to show a list of custom taxanomy terms assigned to the current post type with a name and a custom field. (Created with Advanced Custom Fields)
Currently I use the following code, to show a list of the custom taxanomy terms assigned to the current post:
echo '<ul class="taxanomy-name">';
echo get_the_term_list( $post->ID, 'taxanomy-name', '<li>', ',</li><li>', '</li>' );
echo '</ul>';
Allthough I want to show a custom field from each taxanomy term along with the name.
The code for showing the custom field on each taxanomy term page template is:
the_field('custom-field-name', 'taxanomy-name_ID');
My question is, how do i show the custom field, along with the custom taxanomy term name on the list?
Example:
<ul>
<li>
Taxanomy Term Name 1
<img src="custom-taxanomy-term-1-custom-field-image">
</li>
<li>
Taxanomy Term Name 2
<img src="custom-taxanomy-term-2-custom-field-image">
</li>
</ul>
I hope you can help me..
It’s been bugging me for hours.
Thanks!
Use the
get_the_terms
function instead so you can build the list manually and access theterm_id
for each term.