get_post_data( $post_id ); if ( empty( $post_data ) ) { return array( '@type' => $this->type ); } $schema = array( '@type' => $this->type, '@id' => Schema_AI_ID_Builder::service( $post_id ), 'name' => $post_data['title'], 'description' => $post_data['excerpt'], 'url' => $post_data['url'], ); // Image. $image = $this->get_image_data( $post_id ); if ( ! empty( $image ) ) { $schema['image'] = $image; } // Provider — cross-reference to site-wide Organization. Never redefine it here. $schema['provider'] = $this->get_publisher_reference(); // Service type. if ( ! empty( $fields['serviceType'] ) ) { $schema['serviceType'] = $fields['serviceType']; } // Area served. if ( ! empty( $fields['areaServed'] ) ) { $schema['areaServed'] = $fields['areaServed']; } // Offers. if ( ! empty( $fields['offers'] ) ) { $offers = $fields['offers']; if ( is_array( $offers ) && ! isset( $offers['@type'] ) ) { $offers['@type'] = 'Offer'; } $schema['offers'] = $offers; } // Merge remaining AI-detected fields. // NOTE: aggregateRating and review are intentionally excluded — Google's // Rich Results guidelines only support Review snippets on Product pages, // not Service pages. Including them on Service pages causes validation errors. $schema = $this->merge_fields( $schema, $fields, array( 'name', 'description', 'image', 'serviceOutput', 'category', 'termsOfService', 'award', 'brand', 'hasOfferCatalog', ) ); return $schema; } }