facetwp layout builder with acf repeater subfields

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** ‘author’ is Unique name set in advanced tab of layout builder settings for the item,
** loop over the array returned from ACF to build a html string from the subfields and return to layout builder’s
** facetwp_builder_item_value filter
**/

add_filter( ‘facetwp_builder_item_value’, function( $value, $item ) {
if ( ‘author’ == $item[‘settings’][‘name’] ) {
$value = ”;
$authors = get_field( ‘author’ );
if ( !empty( $authors ) ) {
foreach ( $authors AS $author ) {
$value .= $author[‘title’] . ‘ ‘ . $author[‘name’] . ‘<br />’; // create an html string formatted as needed to return
}
}
}
return $value;
}, 10, 2 );
{{/gist}}