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);
      <?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>
        <?php endforeach; ?>
    <?php endif; ?>