Home › Forums › Add-ons › Repeater Field › Taxonomy in repeater field shows ID › Reply To: Taxonomy in repeater field shows ID
I think you and I are trying to do the same thing.
I’ve created a taxonomy called “category” inside of my repeater “asset”, and now i’m trying to retrieve all the names selected from that taxonomy. (I’m also sorting them in ASC order…)
Example of what I’m doing:
<?php
$rows = get_field('asset');
if($rows) {
foreach($rows as $key => $row) {
$column_id[$key] = $row['id'];
}
array_multisort($column_id, SORT_ASC, $rows);
$i = 0;
foreach($rows as $row) {
$taxonomyterm="";
for($i = 0; $i < count($row['category']); $i++) {
$taxonomyterm = $taxonomyterm . $row['category'][$i] -> name . ' ';
}
echo '<div class="mix img ' . $taxonomyterm . '"><img src="' . $row['image'] . '"/><h4>' . $row['name'] . '</h4>' . $row['description'] . '<div class="overlay"><a href="' . $row['file'] . '" class="expand" download>↓</a><a class="close-verlay hidden">x</a></div></div>';
$i++;
}
}
?>
Try this:
<?php
$rows = get_field('explicit_component');
if($rows) {
$i = 0;
foreach($rows as $row) {
$taxonomyterm="";
for($i = 0; $i < count($row['explicit_component_type']); $i++) {
$taxonomyterm = $taxonomyterm . $row['explicit_component_type'][$i] -> name . ' ';
}
echo '<div id="commitments"><h3>' . $taxonomyterm . '</h3>' . $row['explicit_component_text'] . '</div>';
$i++;
}
}
?>
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.