Home › Forums › Front-end Issues › Displaying field with get_terms › Reply To: Displaying field with get_terms
Hey Wozzal, I was having the same issue and my work around for now was this was really close to your code:
<?php // Get the taxonomy's terms
$terms = get_terms(
array(
'taxonomy' => 'news_categories',
'hide_empty' => false,
)
);
?>
<?php // Check if any term exists
if ( ! empty( $terms ) && is_array( $terms ) ) {
// Run a loop and print them all
foreach ( $terms as $term ) { ?>
<a href="<?php echo esc_url( get_term_link( $term ) ) ?>">
<?php echo $term->name; ?>
<?php echo the_field( 'banner_text', $term ); ?>
<img src="<?php echo the_field( 'banner_image', $term ); ?>">
</a>
<?php
}
}
?>
Getting the Term Name and URL was easy. Getting a simple field, like a “Text Field” from ACF was straight forward too using something like:
<?php echo the_field( 'banner_text', $term ); ?>
I really wanted to use an array for the image but that didn’t want to work so I opted for image URL instead as my work around and just echoed this with no var:
<img src="<?php echo the_field( 'banner_image', $term ); ?>">
If you did ever figure out how to do this with the Image Array please let me know.
Thanks!
Andy
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.