Review Schema for Custom post type
-
Hi,
I’m struggling to get all the needed information correct for the schema on my custom post type. I decided to do it manually, but I don’t now how to get the rating data out of the review summary.
My code snippet looks like this:function cwpai_add_kirpputori_schema() { if (is_singular('kirpputori')) { $post_id = get_the_ID(); $business_name = get_field('kirpputorin_nimi', $post_id); $description = get_field('description', $post_id); $url = get_field('website', $post_id); $address = get_field('osoite', $post_id); $image = get_field('image', $post_id); $schema = array( '@context' => 'https://schema.org', '@type' => 'LocalBusiness', 'name' => $business_name, 'description' => $description, 'url' => $url, 'image' => $image['url'], // Add the image URL 'address' => array( '@type' => 'PostalAddress', 'streetAddress' => $address, ), ); echo '<script type="application/ld+json">'.json_encode($schema).'</script>'; } } add_action('wp_head', 'cwpai_add_kirpputori_schema');
How to get the values for AggregateRating to get the review schema correct? Where is this data stored in Site Reviews plugin?
'aggregateRating' => array( '@type' => 'AggregateRating', 'ratingValue' => $ratingValue, 'bestRating' => $bestRating, 'worstRating' => $worstRating, 'reviewCount' => $reviewCount, ),
Thank you in advance ??
Example url:
https://kirpputorit24.fi/kirpputori/bella-kirppi/The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Review Schema for Custom post type’ is closed to new replies.