Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

New filter: allow non-core post types in Relationship ACF field #177

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/class-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,17 @@ protected function register_graphql_field( $type_name, $field_name, $config ) {
foreach ( $value as $post_id ) {
$post_object = get_post( $post_id );
if ( $post_object instanceof \WP_Post ) {
$post_model = new Post( $post_object );
$relationship[] = $post_model;
$post_model = new Post( $post_object );

/**
* Allow for filtering of the post model. In case a non-core defined post-type is being targeted.
*
* @param mixed|null $post_model GraphQL Model
* @param mixed|null $post_object Root ACF Field value.
* @param AppContext $context AppContext instance.
* @param ResolveInfo $info ResolveInfo instance.
*/
$relationship[] = apply_filters( 'graphql_acf_relationship_model', $post_model, $post_object, $context, $info );
}
}
}
Expand Down