Created
July 30, 2018 21:36
-
-
Save djrmom/856458358af947e4788fc02ffc54e3f4 to your computer and use it in GitHub Desktop.
facetwp layout builder with acf repeater subfields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
in the:
if ( 'author' == $item['settings']['name'] )
are 'setting' and 'name' your parametrs ?
Could you insert here screen of your ACF repeater fileds ?