diff --git a/src/Base/Repositories/AbstractRepository.php b/src/Base/Repositories/AbstractRepository.php index 2424f20..b9cf9f5 100644 --- a/src/Base/Repositories/AbstractRepository.php +++ b/src/Base/Repositories/AbstractRepository.php @@ -225,6 +225,9 @@ public static function getGlobalFields(): array */ public function transform(WP_Post $post) { + $GLOBALS['post'] = $post; + setup_postdata($post); + $data = [ 'id' => $post->ID, 'title' => $post->post_title, @@ -237,6 +240,8 @@ public function transform(WP_Post $post) $data = $this->assignFields($data, $post); + wp_reset_postdata(); + return $data; }