Last active
March 16, 2018 11:01
-
-
Save mrfoxtalbot/33cc3173de59d2e7f3b26c0b0a7968b0 to your computer and use it in GitHub Desktop.
Use ACF to list term icons/images in a custom WordPress taxonomy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// load all 'category' terms for the post | |
$terms = get_the_terms( get_the_ID(), 'nombre_taxonomia'); | |
foreach ( $terms as $term ) { | |
echo ' <div class="tax-icons">'; | |
// we will use the first term to load ACF data from | |
if( !empty($terms) ) { | |
$term = array_pop($terms); | |
$custom_field = get_field('nombre_campo_icono', $term ); | |
echo '<img src="'; | |
echo $custom_field; | |
echo ' ">'; | |
} | |
echo '<div class="tax-name">'; | |
echo $term->name; | |
echo '</div>'; | |
echo '</div>'; | |
} ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment