Support

Account

Home Forums General Issues Display taxonomy subfield term names in table

Solved

Display taxonomy subfield term names in table

  • I created a repeater field (accreditations) containing a taxonomy subfield (organization) and text subfield (points). So for each row I can select one taxonomy term and put the associated points in the text subfield.

    Now I would like to display the organizations (taxonomy terms) and points (text inputs) in a table. Tried the code below, which shows the points, but does not show the organizations (term names).

    function custom_accreditations () {
    	ob_start();
    		if(have_rows('accreditations')):
    			echo '<div><figure class="wp-block-table"><table class="accreditaties"><tbody><tr><td><strong>Organization</strong></td><td><strong>Punten</strong></td></tr>';
    			while (have_rows('accreditations')) : the_row();
    				$term = get_sub_field('organization');
    				$points = get_sub_field('points');
    				if( $term ):
    				$organization = $term->name;
    				echo '<tr><td>'.$organization.'</td><td>'.$punten.'</td></tr>';
    				endif;
    			endwhile;
    			echo '</tbody></table></figure></div>';
    		endif;
    	$content = ob_get_clean(); // store buffered output content.
    	return $content;
    }
    add_shortcode( 'accreditatiepunten', 'custom_accreditations' );

    What am I doing wrong? Anyone know how to display the taxonomy term names correctly?

  • In the taxonomy subfield, setting the return value from Term id to Term object solved the issue.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.