Only index published posts via ACF relationship fields

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

add_filter( ‘facetwp_index_row’, function( $params, $class ) {
if ( ‘YOUR_FACET_NAME_HERE’ == $params[‘facet_name’] ) {
$post_id = (int) $params[‘facet_value’];
if ( ‘publish’ != get_post_status( $post_id ) ) {
$params[‘facet_value’] = ”; // empty the value to prevent indexing
}
}
return $params;
}, 10, 2 );
{{/gist}}