facetwp array handling in layout builder

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php

/** for facetwp’s layout builder output a comma-deliminated list of a ACF field saved as an array **/
add_filter( ‘facetwp_builder_item_value’, function( $value, $item ) {
if ( ‘acf/field_5a96b81f3d58c’ == $item[‘source’] ) { // change ‘acf/field_5a96b81f3d58c’ to the acf field source, you’ll need this version of how the fields are named
if ( is_array( $value ) && !empty( $value ) ) {
return implode( ‘, ‘, $value ); // ‘, ‘ – the delimiter can be changed to other characters or even html
} else {
return ”;
}
}
return $value;
}, 10, 2 );
{{/gist}}