Issue with injecting since upate

#1019982
  • Resolved Jack Brown
    Rank Math free

    Hello,

    Since the update due to the issue with Divi, our injecting of review schema has stopped working. THere seems to be some hard final override now preventing our injection.

    I’m using the rank_math/json_ld filter to inject custom aggregateRating and review fields into the Product schema on select product pages. The code runs correctly — I can see the <!– filter ran –> comment, and the $data[‘@graph’] is modified inside the filter.

    However, the injected data (specifically aggregateRating and review) does not appear in the rendered JSON-LD output, even though it’s present in the PHP $data object at the point of return.

    There is no issue site-wide — only on certain products where I’m injecting reviews from a hardcoded source.

    Can you confirm:

    Does Rank Math run a final sanitisation or override that might strip aggregateRating and review unless specific conditions are met?

    Is there a whitelist or expected field structure that would cause injected properties to be discarded?

    Is there a documented way to reliably inject only the review and rating blocks via rank_math/json_ld, without replacing the full Product schema or switching to a custom schema template?

    We use Divi and im working in the rank-math.php child theme file. The London Dispensary

    Thanks.

Viewing 1 replies (of 1 total)
  • Hello,

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

    Can you please share the filter code you’re using on your website so that we can check that further for you? You can use a tool like https://pastebin.com/ to share the code with us.

    However, please note that Rank Math automatically fetches the reviews from WooCommerce, but if you added any custom reviews, Rank Math will not overwrite them. Here’s an example on how you can add the aggregateRating to your product schema:

    add_filter('rank_math/snippet/rich_snippet_product_entity', function ($entity) {
    	$entity['aggregateRating'] = [
    		'@type'       => 'AggregateRating',
    		'ratingValue' => YOUR_RATING_VALUE_HERE,
    		'bestRating'  => '5',
    		'worstRating' => '1',
    		'ratingCount' => YOUR_RATING_COUNT_HERE,
    	];
    	return $entity;
    });
    

    Please note that you shouldn’t add any custom-made rating to your product schema, otherwise Google can penalize you for spamming.

    Looking forward to helping you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Issue with injecting since upate’ is closed to new replies.