Home › Forums › General Issues › Custom Taxonomy Archive Issues › Reply To: Custom Taxonomy Archive Issues
The term_id is drawn from the term in your loop of the results from get_terms. WP does not automatically generate the id that you need. These are special IDs that ACF needs to locate your data.
foreach ( $terms as $term ) {
// The $term is an object, so we don't need to specify the $taxonomy.
$term_link = get_term_link( $term );
// If there was an error, continue to the next term.
if ( is_wp_error( $term_link ) ) {
continue;
}
// We successfully got a link. Print it out.
echo '<div class="col-lg-3"><a href="' . esc_url( $term_link ) . '">' . $term->name . '</a></div>';
// show custom fields for the term
// this id will be generated for each term
$id = $term->slug.'_'.$term->term_id;
the_field('my_first_custom_field', $id);
the_field('my_second_custom_field', $id);
}
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.