Connect Site Review to Rank Math

[ad_1]

Try using the integration.

add_filter(‘site-reviews/schema/LocalBusiness’, function ($schema) {

    $schema[‘address’] = [

        ‘@type’ => ‘PostalAddress’,

        ‘streetAddress’ => ‘123 Main St’,

        ‘addressLocality’ => ‘City’,

        ‘addressRegion’ => ‘State’,

        ‘postalCode’ => ‘Zip’,

    ];

    return $schema;

–> What do we have to write here for “recipes” instead of “local business”?

Please enable the RankMath Pro integration and then flush the WP Rocket page cache. Once you have done that let me know so I can check the schema on the page.

By the way, I don’t see the screenshots you referenced.

I cleared the WP Rocket Cache.

Unfortunately I could not upload the pictures

I just tested the RankMath integration and it works for me.

Here is what I did:

1. Enable the RankMath Pro integration in the Settings.

2. Enable the schema option on either the Latest Reviews or Rating Summary blocks.

3. Save the page.

4. Open the Schema Generator

5. Select the Recipe schema and fill in the schema information. Make sure to set the Review Location correctly. Once done, click “Save for this Post).

6. Update the page

7. Open the RankMath panel and click the Schema Preview icon and check the schema to see if the AggregateRating schema is on the page. If you don’t see it, refresh the page and check again.

something can’t be right. we get the feedback: Field “aggregateRating” is missing

did it work for you when you tested it with our site?

it is drawn in our code validation, but not adopted by rank math. In other words, if I run the test for rich search results (https://search.google.com/test/rich-results?hl=de) over it, the rating is missing.

I saw that there was a similar topic before with products and woocommerce.(https://projectdmc.org/support/topic/aggregaterating-schema-doesnt-worki/) For us it’s recipes. Something like this was used here:

Could this help us?

**

 * Filter to change the Rank Math schema data for Product.

 * @param array $entity

 * @return array

 */

add_filter(‘rank_math/snippet/rich_snippet_product_entity’, function ($entity) {

    $entity[‘@id’] = get_permalink().’#product’;

    return $entity;

});

or this possibility? here is the following code for wordpress from rank math:

add_filter('rank_math/snippet/rich_snippet_product_entity', function ($entity) {

$score = get_post_meta(get_the_ID(), 'users_rating', true); // Replace with your rating post meta.

$count = get_post_meta(get_the_ID(), 'users_rating_count', true); // Replace with your rating count post meta.

$entity['aggregateRating'] = array(

'@type'       => 'aggregateRating',

'ratingValue' => $score,

'ratingCount' => $count,

);

return $entity;

});

could this be adapted to the site review plugin?


can you help me with the appropriate functions?

I’m not sure why the integration is not working for you. However, if you want to do the code snippet route, this might work:

add_filter('rank_math/snippet/rich_snippet_recipe_entity', function ($entity) {
    $score = get_post_meta(get_the_ID(), '_glsr_average', true);
    $count = get_post_meta(get_the_ID(), '_glsr_reviews', true);
    if (empty($score)) {
        return $entity;
    }
    $entity['aggregateRating'] = [
        '@type' => 'aggregateRating',
        'ratingValue' => $score,
        'ratingCount' => $count,
        'bestRating' => '5',
        'worstRating' => '0'
    ];
    return $entity;
});

it is drawn in our code validation, but not adopted by rank math.

You mean it appears when you preview the schema, but not when you use the Rich Results tool? That sounds like a page caching issue.

many many thanks! now it works – great 🙂

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer