Support

Account

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);
    }