src/properties/class-papi-property-post.php
public function format_value( $value, $slug, $post_id ) {
		$meta_key = $this->get_setting( 'meta_key' );

		if ( ! empty( $meta_key ) ) {
			$args = [
				'fields'         => 'ids',
				'meta_key'       => $meta_key,
				'meta_value'     => $value,
				'posts_per_page' => 1,
				'post_type'      => $this->get_setting( 'post_type' ),
			];

			$query = new WP_Query( $args );

			if ( ! empty( $query->posts ) ) {
				$value = $query->posts[0];
			}
		}

		$post = $this->default_value;

		// Allow only id to be returned.
		if ( ! papi_is_admin() && $this->get_setting( 'fields' ) === 'ids' ) {
			$post = $this->get_post_value( $value );
		} else if ( ! empty( $value ) ) {
			$post = get_post( $value );
		}

		if ( empty( $post ) ) {
			return $this->default_value;
		}

		if ( is_object( $post ) && empty( $post->ID ) ) {
			return $this->default_value;
		}

		return $post;
	}
public function format_value( $value, $slug, $post_id ) {
		$meta_key = $this->get_setting( 'meta_key' );

		if ( ! empty( $meta_key ) ) {
			$args = [
				'fields'         => 'ids',
				'meta_key'       => $meta_key,
				'meta_value'     => $value,
				'posts_per_page' => 1,
				'post_type'      => $this->get_setting( 'post_type' ),
			];

			$query = new WP_Query( $args );

			if ( ! empty( $query->posts ) ) {
				$value = $query->posts[0];
			}
		}

		$post = $this->default_value;

		// Allow only id to be returned.
		if ( ! papi_is_admin() && $this->get_setting( 'fields' ) === 'ids' ) {
			$post = $this->get_post_value( $value );
		} else if ( ! empty( $value ) ) {
			$post = get_post( $value );
		}

		if ( empty( $post ) ) {
			return $this->default_value;
		}

		if ( is_object( $post ) && empty( $post->ID ) ) {
			return $this->default_value;
		}

		return $post;
	}
Format the value of the property before it's returned
to WordPress admin or the site.

@param  mixed  $value
@param  string $slug
@param  int    $post_id

@return array