ACF: Exclude Current Post from Relationship CPT

When using the relationship ACF field, this snippet will hide the current post from being listed in a list of the specified CPT.

In this example, the CPT is ‘Events’ and ‘related_events’ is the name of the ACF Relationship field.
$args uses the WP_Query arguments to find the overall list.
$field is the field name.
$post is the current post ID being edited.

function exclude_current_event( $args, $field, $post ) {
	$args['post__not_in'] = array( $post );
	return $args;
add_filter( 'acf/fields/relationship/query/name=related_events', 'exclude_current_event', 10, 3 );
Additional Reading:

Leave a Reply

Your email address will not be published. Required fields are marked *