Home › Forums › General Issues › Taxonomy Term Field in Categories › Reply To: Taxonomy Term Field in Categories

Those items are fields from a taxonomy. Say you’re wanting to list out the default category taxonomy, you’d need to do something like:
$terms = get_terms( 'category' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li>' . $term->name . '</li>';
}
echo '</ul>';
}
That will output the name of all the categories you’ve created. If you want to output your custom field as well you’ll add your get_field() like:
$terms = get_terms( 'category' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li>' . $term->name . ' - ' . get_field('short_description', $term->taxonomy . '_' . $term->term_id) . '</li>';
}
echo '</ul>';
}
For the get_field() function you’re passing your field name short_description along with the $term->taxonomy and $term->term_id separated by an underscore.
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.