From e1a3f2b9fe235561ca78a264196d1ad5eadd7161 Mon Sep 17 00:00:00 2001 From: Matt Antone Date: Tue, 17 Aug 2021 09:17:21 -0700 Subject: [PATCH 1/2] now checking post status --- src/class-config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class-config.php b/src/class-config.php index 927f2b3..08ea4cd 100644 --- a/src/class-config.php +++ b/src/class-config.php @@ -687,7 +687,7 @@ protected function register_graphql_field( string $type_name, string $field_name if ( ! empty( $value ) && is_array( $value ) ) { foreach ( $value as $post_id ) { $post_object = get_post( $post_id ); - if ( $post_object instanceof \WP_Post ) { + if ( $post_object->status === 'publish' && $post_object instanceof \WP_Post ) { $post_model = new Post( $post_object ); $relationship[] = $post_model; } From 7f626b3920b0df61fa4a7c9e25b5b951f339c34e Mon Sep 17 00:00:00 2001 From: Matt Antone Date: Tue, 17 Aug 2021 10:13:58 -0700 Subject: [PATCH 2/2] corrected condition --- src/class-config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class-config.php b/src/class-config.php index 08ea4cd..058a594 100644 --- a/src/class-config.php +++ b/src/class-config.php @@ -687,7 +687,7 @@ protected function register_graphql_field( string $type_name, string $field_name if ( ! empty( $value ) && is_array( $value ) ) { foreach ( $value as $post_id ) { $post_object = get_post( $post_id ); - if ( $post_object->status === 'publish' && $post_object instanceof \WP_Post ) { + if ( $post_object->post_status == 'publish' && $post_object instanceof \WP_Post ) { $post_model = new Post( $post_object ); $relationship[] = $post_model; }