When using the relationship ACF field, this snippet will only show the published items of the specified CPT.
In this example, the CPT is ‘Services’ and ‘services_list’ is the name of the ACF Relationship field.
$options uses the WP_Query arguments used to specify the post status we want.
function cpt_services_relationship_filter( $options ) {
$options['post_status'] = array( 'publish' );
return $options;
}
add_filter( 'acf/fields/relationship/query/name=services_list', 'cpt_services_relationship_filter' );
Additional Reading:
- ACF Docs: Relationship
- ACF Docs: Relationship Query

Leave a Reply