get_post_data( $post_id ); if ( empty( $post_data ) ) { return array( '@type' => $this->type ); } $schema = array( '@type' => $this->type, '@id' => Schema_AI_ID_Builder::article( $post_id ), 'headline' => $post_data['title'], 'description' => $post_data['excerpt'], 'mainEntityOfPage' => Schema_AI_ID_Builder::ref( Schema_AI_ID_Builder::webpage( $post_id ) ), 'datePublished' => $post_data['date'], 'dateModified' => $post_data['modified'], 'wordCount' => $post_data['word_count'], 'isPartOf' => Schema_AI_ID_Builder::ref( Schema_AI_ID_Builder::webpage( $post_id ) ), ); // Image. $image = $this->get_image_data( $post_id ); if ( ! empty( $image ) ) { $schema['image'] = $image; } // Author — cross-reference to the Person entity, not a full inline definition. $author_ref = $this->get_author_reference( $post_id ); if ( ! empty( $author_ref ) ) { $schema['author'] = $author_ref; } // Publisher — cross-reference to the site-wide Organization entity. $schema['publisher'] = $this->get_publisher_reference(); // Article section from categories. $categories = $this->get_categories( $post_id ); if ( ! empty( $categories ) ) { $schema['articleSection'] = implode( ', ', $categories ); } // Merge any AI-detected fields. $schema = $this->merge_fields( $schema, $fields, array( 'headline', 'description', 'image', 'author', 'publisher', 'articleSection', 'wordCount', 'keywords', 'articleBody', 'about', 'inLanguage', ) ); return $schema; } }