Skip to content

Instantly share code, notes, and snippets.

@joseyaz
Created February 7, 2018 09:16
Show Gist options
  • Save joseyaz/07d22b462185b958df80ecb56c6b8cc1 to your computer and use it in GitHub Desktop.
Save joseyaz/07d22b462185b958df80ecb56c6b8cc1 to your computer and use it in GitHub Desktop.
functions Facets ACF Relationship Fields
/*
=============================================================*/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'via_sector' == $params['facet_name'] ) {
$values = (array) $params['facet_value']; // an array of post IDs (it's already unserialized)
foreach ( $values as $val ) {
$params['facet_value'] = $val;
$params['facet_display_value'] = get_the_title( $val );
$class->insert( $params ); // insert each value to the database
}
// skip the default indexing query
return false;
}
return $params;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment