Support

Account

Home Forums Add-ons Repeater Field Display taxonomy name in repeater field instead of ID

Solved

Display taxonomy name in repeater field instead of ID

  • Hi

    i use a repeater field (dates) with 3 fields.
    for the field ‘location’ is linked with taxonomy ‘locations’, i can’t get his name but just the ID. Anyone has an idea please ?
    thanks a lot

    
    	<?php if( have_rows('dates') ): ?>
    	<?php while( have_rows('dates') ): the_row(); 
    		// vars
    		  the_sub_field('date_event');
     		  the_sub_field('hours');
    		  $variable = get_sub_field( 'location' );
        echo   $variable;
    		?>
      <?php endwhile; ?>
    <?php endif; ?>
    
  • this is what i got :
    Array ( [0] => Array ( [date_event] => 05/02/2015 [location] => 12 [hours] => 20h ) )

    How can i convert location id (12) to his name please ???

    thanks

    • James

    • June 24, 2016 at 8:59 pm

    Hi @pipoulito,

    Thanks for the post.

    You will need to ensure that you have set the return type to term object and then have the following code to display the term name:

    <?php 
    
    $term = get_sub_field('location');
    
    if( $term ): ?>
    
    	<h2><?php echo $term->name; ?></h2>
    	
    
    <?php endif; ?>
    
Viewing 3 posts - 1 through 3 (of 3 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.