Hi all
as the object says, I’m using ACF fields in a portfolio page layout.
- I have a TAXONOMY field with checkboxes to select the item category
- Actually I’m trying to show multiple categories (2, for example)
- I have my child theme
- I’m working on the framework/views/integrity/content-portfolio.php file
- I found this Working with array values
- And this, more specific Display multiple values
If I use this (from the first of the two links)
<?php
$values = get_field('field_name');
if($values)
{
echo '<ul>';
foreach($values as $value)
{
echo '<li>' . $value . '</li>';
}
echo '</ul>';
}
// always good to see exactly what you are working with
var_dump($values);
?>
I get a list of IDs (and I really can’t understand how to convert them to category names)
If I use the second link’s code
<?php
$terms = get_field('taxonomy_field_name');
if( $terms ): ?>
<ul>
<?php foreach( $terms as $term ): ?>
<h2><?php echo esc_html( $term->name ); ?></h2>
<p><?php echo esc_html( $term->description ); ?></p>
<a href="<?php echo esc_url( get_term_link( $term ) ); ?>">View all '<?php echo esc_html( $term->name ); ?>' posts</a>
<?php endforeach; ?>
</ul>
<?php endif; ?>
I get nothing inside the h2 tags.
Any idea?