Repeater ACF field added to a Taxonomy Term isn't displaying on Taxonomy archive template

Description:

We have an ACF field group associated with a taxonomy called Service that contains a Partners repeater field. We want to display the field on the archive template associated with the taxonomy terms.

We have tried putting it directly into the template and tried wrapping a Query around the repeater dynamically using the Archive Taxonomy and Archive Term, to see if that picks up the data but it still doesn’t work.

Is the repeater missing a Location option for the current taxonomy term?

To confirm, we used the exact same ACF field group with a custom post type instead of a custom taxonomy and it worked perfectly in the template, so it is not an issue with the fields themselves.

@Louis, this is a fairly urgent issue as it is affecting our ability to release a site. Any guidance you can provide will be very much appreciated.

Screenshots, screen recording, code snippet

Screenshot 2024-04-24 at 20.51.39

Screenshot 2024-04-24 at 20.51.52

Environment info

  • WordPress version: 6.5.2
  • Cwicly Plugin version: 1.4.1.3

Confirming also that both text and image fields work fine with taxonomy archives.

So far, it is only:

  1. Repeater fields
  2. Relationship fields
  3. Visibility conditions

…that don’t work.

We have confirmed this is definitely an issue on the Cwicly side, the ACF fields work perfectly using custom code - we have had to drop in code blocks as a workaround.

@Louis, here is our working code for both relationship fields and repeater fields:

Relationship fields:

<?php
add_filter( 'cwicly/query/args', function( $query_args, $attributes, $id ) {
	if ($id === 'query-c6041ea') {
		$term = get_queried_object();
		$partners = get_field("commercial_partners", $term);

		$query_args['post__in'] = $partners;
	}
	return $query_args;
}, 10, 3 );
?>

Repeater fields:

<div class="metrics post-grid">
<?php
$term = get_queried_object();
$stats = get_field( 'stats', $term);

if ( $stats ) {
  foreach ( $stats as $stat ) {
    $stat_title = $stat['title'];
    $stat_content = $stat['content'];
    ?>
    <div class="featured-metric post-content">
      <h2><?php echo $stat_title; ?></h3> 
      <p><?php echo $stat_content; ?></p>
    </div>
    <?php
  }
}
?>
</div>

For the repeaters, I am guessing that as there is no way to set the taxonomy archive as the location, Cwicly is not automatically detecting that the current context is a taxonomy archive and passing the term as the second parameter.

Regarding the relationship query, I think it is probably the same issue - there is no way to specify the current taxonomy archive as the location in the “Posts In”:

Finally, this same issue also affects visibility conditions, we have had to use a custom function for this also, instead of being able to use the built-in ACF field features:

function service_has_stats() {
	$has_stats = false;
	$term = get_queried_object();
	$stats = get_field( 'stats', $term);
	
	if ( $stats ) {
	  $has_stats = count($stats) > 0;
	}
	return $has_stats;
}