RankMaths x Site Reviews issue

  • Hey, I’m using RankMaths on my site and I’m extremely happy! My site consists of a WooCommerce shop, RankMaths for SEO and Site Reviews Plugin for better ratings than would be possible with WooCommerce (example: https://testhelden.com/produkt/bundeswehr-einstellungstest/). Unfortunately, the two rich snippets from RankMath and the Site Reviews plugin don’t match. What can I do about sending only one product scheme to Google?
    According to the support from the Site Reviews plugin, I should ask you the following: You will need to contact the “SEO plugin Rank Math” support team and ask them how to add a custom @id property to the schema on a per-page basis.

    I would be very grateful if you can help. Thank you and best regards from Germany.

    • This topic was modified 2 weeks, 1 day ago by TestHelden.
Viewing 15 replies - 1 through 15 (of 15 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    Also, thank you for your kind words about Rank Math, we are happy you like it!

    About your issue, if you want, you can share with the support the following code snippet, which you can use to modify any property in any page:

    **
     * Filter to change the schema data.
     * Replace $schmea_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_{$schema}_entity", function( $entity ) {
     return $entity;
    });

    This filter (and many others) can be found here: https://rankmath.com/kb/filters-hooks-api-developer/

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hey, thanks for this information! But how can I practically combine the two schemes now? That would be super interesting to know. Do I have to exchange $ schema with $ post_id or what do I have to do? Could you help me with this?

    Many thanks

    In the rich snippet of the Site Review Plugin, the following is passed on as an ID. In theory, I would just have to tell RankMaths that RankMaths in the schema also uses this ID, right? How do I get it done? The ID corresponds to the product URL
    Many thanks

    Hey, I have (hopefully correct) brought the two together using the following code.

    **
     * 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;
    });

    Unfortunately, the entire rich snippet with the stars is not shown in the preview under “Edit product” in the RankMath plugin. If we can manage that together, I’m the happiest person and will recommend the two plugins in combination with WooCommerce to every customer and use them operationally. So far I am incredibly satisfied.

    According to the scheme, all important information should now be contained in a rich snippet (see screenshot). I hope we get this one bug fixed, so that everything is shown correctly in the preview so that I can give my editors access. They should align themselves with the RankMath preview and with the recommendations themselves. Therefore, the star display would be very important to me.

    Hello,

    Please use the following filter to change the rating value in the SERP Preview:

    
    add_filter( 'woocommerce_product_get_average_rating', function( $rating ) {
    	if ( ! is_admin() ) {
    		return $rating;
    	}
    
    	return 1; // Change this with Site Reviews Plugin function/code to get the ratings value.
    } );
    
    

    I hope that helps.

    The Site Review Plugin Support gave me the following feedback on the source code:

    1. Is that a Woocommerce hook or a RankMaths hook, and do you have an URL that I can view which provides documentation for it?

    2. What does the $rating variable contain?

    You can use this to find out: glsr_debug($rating);

    3. Do you have access to the product post ID in that hook? Or, does get_the_ID() work in that hook to get the product ID?

    4. Have you tried using the glsr_get_rating helper function? Please see the Help > Functions page for more info.

    I hope we can do it ..: D

    $ratingInfo = glsr_get_rating([
        'assigned_to' => 'post_id',
    ]);
    
    // OR:
    
    $ratingInfo = apply_filters('glsr_get_rating', null, [
        'assigned_to' => 'post_id',
    ]);

    I think this should be the code to get the star-ratings.
    How can I include this in your sample code?

    Hello,

    I have modified the above provided snippets to the following. Could you please try it and let us know if it works.

    add_filter( 'woocommerce_product_get_average_rating', function( $rating ) {
    	if ( ! is_admin() ) {
                  $ratingInfo = apply_filters('glsr_get_rating', null, [
                  'assigned_to' => 'post_id',
                     ]);
                    $rating = $ratingInfo
    
    		return $rating;
    	}
    
    	return 1; // Change this with Site Reviews Plugin function/code to get the ratings value.
    } );
    

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    syntax error, unexpected 'return' (T_RETURN)
    Cannot safe this code in functions.php .. 🙁

    add_filter( 'woocommerce_product_get_average_rating', function( $rating ) {
    	if ( ! is_admin() ) {
                  $ratingInfo = apply_filters('glsr_get_rating', null, [
                  'assigned_to' => 'post_id',
                     ]);
                    $rating = $ratingInfo;
    				
    		return $rating;
    	}
    
    	return 1; // Change this with Site Reviews Plugin function/code to get the ratings value.
    } );

    The syntax error came with the “;”.

    add_filter( 'woocommerce_product_get_average_rating', function( $rating ) {
    	if ( ! is_admin() ) {
                  $ratingInfo = apply_filters('glsr_get_rating', null, [
                  'assigned_to' => 'post_id',
                     ]);
                    $rating = $ratingInfo[0];
    				
    		return $rating;
    	}
    
    	return 1; // Change this with Site Reviews Plugin function/code to get the ratings value.
    } );

    After that I adjusted the code like so. Now the following errors occur:

    Uncaught Error: Cannot use object of type stdClass as array in wp-content/themes/buddyboss-theme-child/functions.php:141
    Stack trace:
    #0 wp-includes/class-wp-hook.php(289): {closure}()
    #1 wp-includes/plugin.php(206): WP_Hook->apply_filters()
    #2 wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php(751): apply_filters()
    #3 wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php(690): WC_Data->get_prop()
    #4 wp-content/plugins/woocommerce/templates/loop/rating.php(28): WC_Product->get_average_rating()
    #5 wp-content/plugins/woocommerce/includes/wc-core-functions.php(344): include(‘/var/www/vhosts…’)
    #6 wp-content/plugins/woocommerce/includes/wc-template-functions

    Hello,

    I think we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    The woocommerce_product_get_average_rating filter will work only when your product page has reviews. The product page you added in the Sensitive Data Section is showing 0 reviews so this filter will not work. In the comment section, I see some reviews but it doesn’t look like a Product review it looks more like a comment review. If the Star reviews plugin is adding those reviews then the filter might not work if the Star review plugin is not using the WooCommerce product review filters in their core files.

    You can change the star reviews in SERP Preview in backend only by using WooCommerce filter as Rank Math supports only WooCommerce reviews.

    I hope this clears the confusion.

    Hey

    sorry! I just noticed that the reviews were not displayed. That was probably because we integrated the SKUs. Now you can see 4 published reviews. Perhaps this will help you to recognize the error again. That would be extremely great.

    Hello,

    I see the reviews on your site now but in the backend, in SERP Preview the ratings are not showing. So it certainly means the Review plugin which you are using is not using the woocommerce_average_rating filter. Unfortunately, there is nothing we could do to fix this as Rank Math currently supports only WooCommerce ratings. You can ignore the missing reviews in the backend, it won’t affect your site’s ranking as on frontend all the Product schema is properly added.

    I hope that helps. If there is anything else, please let us know.

    Thank you.

Viewing 15 replies - 1 through 15 (of 15 total)

You must be logged in to reply to this ticket.