Home › Forums › ACF PRO › Category images › Reply To: Category images
We need to do some debugging so that we can see what’s actually going on. The code you have looks like it should be working.
Alter your code to add the output statements I’ve added below and let me know what gets output
<?php if (have_rows('zichtbare_diensten')) :
$term_array = array();
while (have_rows('zichtbare_diensten')) : the_row();
$term_id = get_sub_field('zichtbare_diensten');
// display $term_id to see what it contains
echo '<br />TERM ID: '; var_dump($term_id);
$term = get_category($term_id);
// display $term and see what it contains
echo '<br />TERM: '; var_dump($term);
$term_name = $term->name;
array_push($term_array, $term);
endwhile;
endif;
?>
<?php if (get_row_layout() === 'diensten'): ?>
<div id="diensten-thumbs">
<?php foreach ($term_array as $row): ?>
<div class="dienst" style="background-image: url(<?php the_sub_field('image', $row->term_id) ?>)">
<h3><?php echo $row->name ?></h3>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
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.