FacetWP – don’t index unpublished content from ACF relationship fields

mgibbs189

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

function fwp_check_relationship_post_status( $params, $class ) {
if ( ‘YOUR_RELATIONSHIP_FIELD_NAME’ == $params[‘facet_name’] ) {
$post_id = (int) $params[‘facet_value’];
if ( ‘publish’ != get_post_status( $post_id ) ) {
return false; // skip indexing for this value
}
}
return $params;
}
add_filter( ‘facetwp_index_row’, ‘fwp_check_relationship_post_status’, 10, 2 );
{{/gist}}