Support

Account

Home Forums Add-ons Repeater Field Show Custom Taxonomy name from repeter field with "taxonomy sub field"

Helping

Show Custom Taxonomy name from repeter field with "taxonomy sub field"

  • Hi guys. I have issues with true way to show the name of a Custom Taxonomy.

    Let me explain my situation: I created a “Repeater field” and inside it I have a “Taxonomy sub field”, in this sub field I have selected my custom taxonomy “dato_nutricional” the Field type as Select and the Return Value as ID term. I was using the fallowing code to try to show the taxonomy name:

    <span><?php 
    $sntermino = get_sub_field('sula_nutricional_termino');
    if( $sntermino ): echo $sntermino->name; endif; ?>
    ?></span>

    But I wasn’t has lucky with this. If I only use echo $sntermino with out ->name I have the ID of my taxonomy as value

    Please, can you help me with this issue?

  • Hi Guys. Finally I found the solution!!!!
    I leave for you the solution that I found:

    <?php 
    if( have_rows('repeater_field_name') ): 
    while( have_rows('repeater_field_name') ): the_row(); 
    $tax_val = get_sub_field('taxonomy_sub_field_name');
    $taxonomy = 'custom_taxonomy_name';
    $term_name = get_term($tax_val, $taxonomy);
    if( $tax_val ): echo $term_name->name; 
    endif; 
    endwhile; 
    endif; 
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.