Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created July 30, 2018 21:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/856458358af947e4788fc02ffc54e3f4 to your computer and use it in GitHub Desktop.
Save djrmom/856458358af947e4788fc02ffc54e3f4 to your computer and use it in GitHub Desktop.
facetwp layout builder with acf repeater subfields
<?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 );
@trudoom
Copy link

trudoom commented Mar 17, 2024

Hi,
in the:
if ( 'author' == $item['settings']['name'] )

are 'setting' and 'name' your parametrs ?
Could you insert here screen of your ACF repeater fileds ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment