Created
February 7, 2018 09:16
-
-
Save joseyaz/07d22b462185b958df80ecb56c6b8cc1 to your computer and use it in GitHub Desktop.
functions Facets ACF Relationship Fields
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
/* | |
=============================================================*/ | |
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